This repository was archived by the owner on Nov 18, 2026. It is now read-only.
Repository navigation
Load media with the access token - #130
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The widened ID type leaves a data-quality caller passing unique_id directly to a number-only parameter, causing a type error that needs the same numeric conversion used by the other DQC callers.
1 open issue
What changed in this PR
This PR routes media through authenticated HTTP requests so JWT-only users can view analysis results and download files across the SEED frontend.
Changes:
- Adds a shared media service for URL normalization, authenticated fetching, and download-only blobs.
- Displays reports in sandboxed frames and images as data URLs, while improving analysis lifecycle handling.
- Updates download callers, task ID types, and the Audit Template request method, with regression tests.
Validation was limited to source inspection; builds, tests, and live-backend checks were not run.
| File | Description |
|---|---|
src/app/modules/inventory/inventory.types.ts |
Allows unavailable history files to be null. |
src/app/modules/inventory-detail/detail/grid/documents-grid.component.ts |
Uses authenticated document downloads. |
src/app/modules/inventory-detail/detail/grid/documents-grid.component.spec.ts |
Tests document download delegation. |
src/app/modules/inventory-detail/detail/grid/building-files-grid.component.ts |
Preserves file paths and authenticates downloads. |
src/app/modules/inventory-detail/detail/grid/building-files-grid.component.spec.ts |
Tests building-file downloads. |
src/app/modules/datasets/dataset/dataset.component.ts |
Downloads imports through the media service. |
src/app/modules/datasets/dataset/dataset.component.spec.ts |
Tests import-file downloads. |
src/app/modules/datasets/data-mappings/step3/save-mappings.component.ts |
Converts data-quality IDs to numbers. |
src/app/modules/data-quality/start-modal.component.ts |
Converts data-quality result IDs to numbers. |
src/app/modules/analyses/analysis/analysis.component.ts |
Handles empty views and authenticated downloads. |
src/app/modules/analyses/analysis/analysis.component.spec.ts |
Tests failed analyses and result downloads. |
src/app/modules/analyses/analysis_view/analysis-view.component.ts |
Fetches report content and guards shared-stream updates. |
src/app/modules/analyses/analysis_view/analysis-view.component.spec.ts |
Tests rendering, downloads, and lifecycle guards. |
src/app/modules/analyses/analysis_view/analysis-view.component.html |
Renders sandboxed reports and fetched images. |
src/@seed/utils/index.ts |
Exports the new blob utilities. |
src/@seed/utils/download-blob.ts |
Adds shared blob downloading and URL cleanup. |
src/@seed/utils/download-blob.spec.ts |
Tests download naming and URL cleanup. |
src/@seed/utils/csv-download.ts |
Reuses the blob download utility. |
src/@seed/utils/blob-to-data-url.ts |
Adds observable blob-to-data-URL conversion. |
src/@seed/utils/blob-to-data-url.spec.ts |
Tests data-URL conversion. |
src/@seed/pipes/safe-url/safe-url.pipe.ts |
Removes the unused URL trust pipe. |
src/@seed/api/progress/progress.types.ts |
Supports numeric and string task IDs. |
src/@seed/api/media/media.service.ts |
Centralizes authenticated media access. |
src/@seed/api/media/media.service.spec.ts |
Tests URL validation, authentication, and downloads. |
src/@seed/api/media/index.ts |
Exports the media service. |
src/@seed/api/index.ts |
Exposes media through the API barrel. |
src/@seed/api/cache/cache.service.ts |
Accepts numeric or string cache IDs. |
src/@seed/api/audit-template/audit-template.service.ts |
Changes submission imports to PUT. |
src/@seed/api/audit-template/audit-template.service.spec.ts |
Tests import and export request methods. |
src/@seed/api/analysis/analysis.types.ts |
Makes list-response views optional. |
src/@seed/api/analysis/analysis.service.ts |
Lists analyses without overwriting detail views. |
src/@seed/api/analysis/analysis.service.spec.ts |
Tests list requests and view-state preservation. |
Review effort: Balanced
axelstudios
force-pushed
the
bugfix/authenticated-media
branch
from
November 17, 2026 21:09
417e3c6 to
a339819
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Any background context you want to provide?
The backend serves media at
/api/v3/media/<path>only to authenticated users who can access a record referencing the file. This app signs in with a JWT only, with no Django session. Media was loaded by<iframe>,<img>, and anchor navigations, which don't go throughHttpClient, so the auth interceptor never added the token.As a result, users who signed in only through this app got 401s for analysis reports, result images, and file downloads. That was already the case in production. It now also happens in development, because the backend's dev
/media/route no longer serves files without authentication.Companion to the SEED PR "Fix remaining access-level and data exposure gaps".
What's this PR do?
MediaService(@seed/api/media):/api/v3/media/...URLs. It accepts API URLs, dev/media/URLs, same-origin URLs, and server filesystem paths, and rejects anything that resolves outside/api/v3/media/.application/octet-streamblobs, so an uploaded HTML or SVG file never renders from the app's origin.srcdociframe withsandbox="allow-scripts allow-popups". Withoutallow-same-origin, report scripts can't read the app's storage, including the token, and pages opened from the report keep the sandbox.<base href="about:srcdoc">is inserted so links inside the report resolve within the report.data:URLs, which the CSP allows.MediaService.download.fileinto its rows.getAnalysesrequestsinclude_views=falseand no longer overwrites the page's views with the list endpoint's views, whose files are server paths.downloadBlobandblobToDataUrlutils;csvDownloadnow usesdownloadBlob.SafeUrlPipe.History.fileis nowstring | null, since the backend returns null for files the user can't download.ProgressResponse.unique_idis nownumber | string, since exports, mapping results, and other tasks now return string IDs.CacheService.getCacheEntryaccepts either, and the data quality callers convert their run ID, which is still an integer, withNumber.How should this be manually tested?
Sign in through this app only, with no legacy session in the same browser, then check each of these:
.htmlfile.srcdocreport and its inline scripts aren't blocked.