Skip to content

Conversation

@oatkins8
Copy link
Contributor

@oatkins8 oatkins8 commented Feb 3, 2026

What Issue Does This PR Cover, If Any?

Resolves: #568

What Changed? And Why Did It Change?

Beacons need to download documents that are attached to their associated topics. Previously there was no endpoint to serve these files with proper authentication and authorization. This PR adds a files endpoint that allows beacons to download documents only from topics they have access to. The endpoint uses ActiveStorage streaming to support both full file downloads and partial content requests via Range headers, which is important for efficient delivery of large files.

The accessible_blobs method was added to the Beacon model to provide the authorization layer, ensuring beacons can only access documents from their own topics. The namespace was also standardised from beacons to beacon for consistency across the API.

How Has This Been Tested?

Comprehensive request specs cover authentication, authorization, full downloads, Range header support with single and multiple byte ranges, not found scenarios, and cross-beacon authorization checks. Model specs verify the accessible_blobs method correctly scopes files to the beacon's topics.

oatkins8 and others added 3 commits February 3, 2026 14:52
Singular namespace better reflects that a beacon accesses its own
resources rather than a collection.
Beacons need to scope file access to only documents attached
to their associated topics. The accessible_blobs method provides
this authorization layer by joining through the attachments and
beacon_topics associations to ensure beacons cannot access files
from topics belonging to other beacons.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The endpoint allows beacons to download documents from their
associated topics using the accessible_blobs scope for
authorization. ActiveStorage streaming handles both full file
downloads and partial content requests via Range headers for
efficient delivery of large files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@oatkins8 oatkins8 changed the title Add authenticated file download endpoint for beacons [WIP] Add authenticated file download endpoint for beacons Feb 3, 2026
@oatkins8 oatkins8 marked this pull request as draft February 3, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Download Endpoint

2 participants