Download release assets through the gateway on Fjord Account hosts (#222) #313

Merged
stephen merged 1 commit from stephen/fj-222-release-download-gateway into main 2026-11-11 15:52:59 +00:00
Owner

Fixes fj release download on a Fjord Account host (part of #222). It fetched each asset's browser_download_url with an unauthenticated client. On a Fjord Account host that URL is the forge's web origin, which answers 404 for a private repository (reproduced with fj release download v0.2.0 -R rasterstate/dock-control on shop-dev-01) and must never receive the Fjord bearer.

The asset is now fetched through the gateway with the session, using the same client path as API calls (401 refresh and account-override checks included). The gateway already forwards any path to the instance with a per-user forge token, so no platform change.

Path checks. The gateway has no path allowlist, so fj constrains the request. The asset URL must be on the origin of the release's own page and, decoded, equal /<owner>/<repo>/releases/download/<tag>/<name> for the repository and tag being downloaded, with no query, fragment or dot segments. Anything else is refused before any request. An instance mounted under a base path is refused too, because fj does not know the base the gateway appends to. PAT hosts are unchanged.

Redirects. A redirect to storage on another origin is followed without Authorization (covered by a test).

Not verified here: whether rasterhub's Forgejo accepts the gateway's forge token on the web download route. That needs one run of fj release download v0.2.0 -R rasterstate/dock-control with the new build installed.

Adds percent-encoding as a direct dependency; it was already in Cargo.lock through url. Tests: gateway mapping, refusal matrix, bearer on the gateway fetch, no credential on a cross-origin redirect, path-mounted and wrong-repository refusal, PAT client unchanged. clippy on this host's newer toolchain stops at an existing lint in src/cli/pr_line_comment.rs, untouched here.

Fixes `fj release download` on a Fjord Account host (part of #222). It fetched each asset's `browser_download_url` with an unauthenticated client. On a Fjord Account host that URL is the forge's web origin, which answers 404 for a private repository (reproduced with `fj release download v0.2.0 -R rasterstate/dock-control` on shop-dev-01) and must never receive the Fjord bearer. The asset is now fetched through the gateway with the session, using the same client path as API calls (401 refresh and account-override checks included). The gateway already forwards any path to the instance with a per-user forge token, so no platform change. **Path checks.** The gateway has no path allowlist, so fj constrains the request. The asset URL must be on the origin of the release's own page and, decoded, equal `/<owner>/<repo>/releases/download/<tag>/<name>` for the repository and tag being downloaded, with no query, fragment or dot segments. Anything else is refused before any request. An instance mounted under a base path is refused too, because fj does not know the base the gateway appends to. PAT hosts are unchanged. **Redirects.** A redirect to storage on another origin is followed without `Authorization` (covered by a test). **Not verified here:** whether rasterhub's Forgejo accepts the gateway's forge token on the web download route. That needs one run of `fj release download v0.2.0 -R rasterstate/dock-control` with the new build installed. Adds `percent-encoding` as a direct dependency; it was already in `Cargo.lock` through `url`. Tests: gateway mapping, refusal matrix, bearer on the gateway fetch, no credential on a cross-origin redirect, path-mounted and wrong-repository refusal, PAT client unchanged. clippy on this host's newer toolchain stops at an existing lint in `src/cli/pr_line_comment.rs`, untouched here.
Download release assets through the gateway on Fjord Account hosts (#222)
All checks were successful
ci / check (pull_request) Successful in 21m47s
ci / live-e2e (pull_request) Successful in 3m44s
ci / coverage (pull_request) Successful in 3m55s
987aa91e54
fj release download fetched browser_download_url with an unauthenticated client.
On a Fjord Account host that URL is the forge's web origin, which answers 404
for a private repository and must never receive the Fjord bearer. The asset is
now fetched from the gateway with the session (refresh and account checks
included) when its URL is exactly the download route of the release being
downloaded, on the origin that release names; any other URL is refused. PAT
hosts are unchanged.
gerri approved these changes 2026-11-11 15:25:52 +00:00
gerri left a comment

Automated Codex review (read-only) of head 987aa91e54.

No confirmed findings in the diff against ~/fleet-week/STANDARDS.md and the surrounding request, refresh, redirect, and download code.

The gateway’s acceptance of forge tokens on the web download route remains unverified, as disclosed in the PR body. No network requests or tests were run.

BLOCKING: 0

Reviewed head 987aa91e54 at 2026-11-11T15:25:51Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 987aa91e54c13aca5822c6b0763b84179c79cd9a. No confirmed findings in the diff against `~/fleet-week/STANDARDS.md` and the surrounding request, refresh, redirect, and download code. The gateway’s acceptance of forge tokens on the web download route remains unverified, as disclosed in the PR body. No network requests or tests were run. BLOCKING: 0 --- Reviewed head 987aa91e54c13aca5822c6b0763b84179c79cd9a at 2026-11-11T15:25:51Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.