Add verified per-invocation account overrides (#157) #307

Merged
stephen merged 2 commits from fj-157-account-override into main 2026-11-10 15:57:20 +00:00
Owner

Step 1 of #157: run a single command as a named account without touching stored credentials. fj --account <login> (or FJ_ACCOUNT) pairs with a personal access token from the environment (FJ_TOKEN, or a host-scoped variable, which wins over the generic one). The login is verified against /user before any other request goes out, so a token that belongs to a different account stops the command instead of acting as someone else. Nothing is written to the keychain, config or token files.

With an override active, fj refuses every other way a request could pick its identity: stored-token, anonymous and web-session fallbacks, custom Authorization or forwarded-auth headers, Sudo (header or query), token and access_token in the URL, the query list or a form-encoded body (Forgejo reads those before the header), and non-PAT hosts. Errors and debug output never include the account or any supplied credential. Multipart uploads (pr attach, release assets) run the same verification before sending anything.

Stored profiles and an auth login --account flow are step 2, as a separate change. Existing behavior without --account is unchanged. Usage and scope are in docs/account-override.md.

Step 1 of #157: run a single command as a named account without touching stored credentials. `fj --account <login>` (or `FJ_ACCOUNT`) pairs with a personal access token from the environment (`FJ_TOKEN`, or a host-scoped variable, which wins over the generic one). The login is verified against `/user` before any other request goes out, so a token that belongs to a different account stops the command instead of acting as someone else. Nothing is written to the keychain, config or token files. With an override active, `fj` refuses every other way a request could pick its identity: stored-token, anonymous and web-session fallbacks, custom `Authorization` or forwarded-auth headers, `Sudo` (header or query), `token` and `access_token` in the URL, the query list or a form-encoded body (Forgejo reads those before the header), and non-PAT hosts. Errors and debug output never include the account or any supplied credential. Multipart uploads (`pr attach`, release assets) run the same verification before sending anything. Stored profiles and an `auth login --account` flow are step 2, as a separate change. Existing behavior without `--account` is unchanged. Usage and scope are in `docs/account-override.md`.
Fence alternate auth carriers and verify multipart account overrides (#157)
All checks were successful
ci / check (pull_request) Successful in 15m8s
ci / coverage (pull_request) Successful in 3m20s
ci / live-e2e (pull_request) Successful in 4m23s
6652e2cb5a
gerri approved these changes 2026-11-10 15:37:05 +00:00
gerri left a comment

Automated Codex review (read-only) of head 6652e2cb5a.

No confirmed correctness, security, or failure-path problems found against STANDARDS.md. Reviewed API requests, multipart uploads, host resolution, direct HTTP helpers, and web fallbacks. Tests were inspected but not run in the read-only sandbox.

BLOCKING: 0

Reviewed head 6652e2cb5a at 2026-11-10T15:37:03Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 6652e2cb5a9a80861ca137c7f990a1fca764ad0b. No confirmed correctness, security, or failure-path problems found against STANDARDS.md. Reviewed API requests, multipart uploads, host resolution, direct HTTP helpers, and web fallbacks. Tests were inspected but not run in the read-only sandbox. BLOCKING: 0 --- Reviewed head 6652e2cb5a9a80861ca137c7f990a1fca764ad0b at 2026-11-10T15:37:03Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.