Scope Fjord OIDC sessions and instances to named accounts (#157 step 2b-i) #309

Merged
stephen merged 5 commits from fj-157-fjord-profiles into main 2026-11-10 19:17:12 +00:00
Owner

Step 2b-i of #157: Fjord gateway accounts become named profiles, so a command can run against a chosen Fjord account the same way step 2a does for PAT accounts. Browser shortcuts, mute and inbox filtering and the work and status instance display still read the legacy host and are step 2b-ii (with scoped session cookies and the remaining maintenance commands); until that lands, named Fjord profiles cover API and instance commands only, and docs/account-override.md says so. #157 stays open until both land.

The manual, loopback PKCE and device OIDC login flows share one named-session completion. The bearer and the identity-bound refresh token go into separate host/account/generation slots that are staged and read back before the descriptor is atomically published, and failed verification, storage or publication leaves the default and the legacy fields and keys untouched. Platform URL and credential storage identity stay separate. Client and direct instance commands resolve the same explicit or default profile with no legacy or cross-account fallback; instance metadata stays per profile; fj auth switch verifies the stored identity, fences the platform destination and the verified host snapshot, and refreshes once on a 401 before moving the default. Refresh takes a hashed account-scoped cross-process lock with generation fencing, adopts a peer's newer bearer (and renews it if it has also expired), and persists a rotated refresh token before any further network work, so a timeout after a successful exchange never spends the grant. Status stays redacted and named OIDC failures suppress provider bodies.

Offline tests: 22 unit tests and four CLI integration tests (device login, two accounts on one platform, one account on two platforms, explicit and default instance selection, missing-profile refusal, failed identity, storage and publication, redaction, two simultaneous clients hitting one initial 401 with exactly one refresh exchange, the publication race, rotation surviving a 503, and switching with an expired bearer). Live interactive browser login and CI coverage are still to be confirmed.

Step 2b-i of #157: Fjord gateway accounts become named profiles, so a command can run against a chosen Fjord account the same way step 2a does for PAT accounts. Browser shortcuts, mute and inbox filtering and the work and status instance display still read the legacy host and are step 2b-ii (with scoped session cookies and the remaining maintenance commands); until that lands, named Fjord profiles cover API and instance commands only, and docs/account-override.md says so. #157 stays open until both land. The manual, loopback PKCE and device OIDC login flows share one named-session completion. The bearer and the identity-bound refresh token go into separate host/account/generation slots that are staged and read back before the descriptor is atomically published, and failed verification, storage or publication leaves the default and the legacy fields and keys untouched. Platform URL and credential storage identity stay separate. Client and direct instance commands resolve the same explicit or default profile with no legacy or cross-account fallback; instance metadata stays per profile; `fj auth switch` verifies the stored identity, fences the platform destination and the verified host snapshot, and refreshes once on a 401 before moving the default. Refresh takes a hashed account-scoped cross-process lock with generation fencing, adopts a peer's newer bearer (and renews it if it has also expired), and persists a rotated refresh token before any further network work, so a timeout after a successful exchange never spends the grant. Status stays redacted and named OIDC failures suppress provider bodies. Offline tests: 22 unit tests and four CLI integration tests (device login, two accounts on one platform, one account on two platforms, explicit and default instance selection, missing-profile refusal, failed identity, storage and publication, redaction, two simultaneous clients hitting one initial 401 with exactly one refresh exchange, the publication race, rotation surviving a 503, and switching with an expired bearer). Live interactive browser login and CI coverage are still to be confirmed.
gerri requested changes 2026-11-10 18:15:14 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head 67bbea3477.

  • Medium src/cli/instances.rs:249
    Invariant: Named OIDC failures must suppress provider bodies (standards 11 and 20). Both named instances list and instances use propagate errors from fetch_listing_once, including the retry at line 256. That helper calls fjord::list_instances, whose non-success errors include the response body. On a supported named profile, a platform 403 or 503 containing account diagnostics therefore exposes them through --debug. This newly enabled named entry point bypasses the sanitization used by login, switch, and refresh. Sanitize named listing errors on both attempts, preserving SessionExpired for refresh. Test provider-body suppression for list and use.

  • Low tests/fjord_profiles.rs:171
    Invariant: Tests must exercise the failure they claim to cover (standard 13). The “wrong” account login receives a token whose email matches that requested account. It fails because no instance-list mock accepts that token, producing 404. It never tests rejection of a platform-accepted bearer belonging to another account. Return an existing account’s accepted token while requesting a different account, then assert that publication and defaults remain unchanged.

BLOCKING: 1

Reviewed head 67bbea3477 at 2026-11-10T18:15:13Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 67bbea3477d2dd03c7f43a29b23ded7a2d3811dc. - **Medium** `src/cli/instances.rs:249` **Invariant:** Named OIDC failures must suppress provider bodies (standards 11 and 20). Both named `instances list` and `instances use` propagate errors from `fetch_listing_once`, including the retry at line 256. That helper calls `fjord::list_instances`, whose non-success errors include the response body. On a supported named profile, a platform 403 or 503 containing account diagnostics therefore exposes them through `--debug`. This newly enabled named entry point bypasses the sanitization used by login, switch, and refresh. Sanitize named listing errors on both attempts, preserving `SessionExpired` for refresh. Test provider-body suppression for list and use. - **Low** `tests/fjord_profiles.rs:171` **Invariant:** Tests must exercise the failure they claim to cover (standard 13). The “wrong” account login receives a token whose email matches that requested account. It fails because no instance-list mock accepts that token, producing 404. It never tests rejection of a platform-accepted bearer belonging to another account. Return an existing account’s accepted token while requesting a different account, then assert that publication and defaults remain unchanged. BLOCKING: 1 --- Reviewed head 67bbea3477d2dd03c7f43a29b23ded7a2d3811dc at 2026-11-10T18:15:13Z by codex exec (read-only sandbox).
Suppress provider bodies in named instance listing errors
Some checks failed
ci / check (pull_request) Failing after 2m38s
ci / coverage (pull_request) Has been skipped
ci / live-e2e (pull_request) Has been skipped
cfa9e3e4c5
gerri requested changes 2026-11-10 18:42:54 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head cfa9e3e4c5.

  • Medium src/config/fjord_scope.rs:11: Invariant: named-profile failures must suppress provider bodies across every request path (standards 11 and 18). Both instances list and instances use call fetch_listing_once, which also fetches Commons. When /api/v1/me/commons returns a 403 or 503, fetch_commons includes the response body in its error, and settle_commons prints that error under --debug before this wrapper can redact it. A normal Commons outage can therefore expose private provider diagnostics in terminal output or captured logs, including after a refresh. This belongs in this PR because named-session error redaction is explicitly promised. Pass the profile redaction policy into the Commons settlement path and suppress bodies before logging. Extend fjord_profile_listing_errors.rs to fail the Commons endpoint as well as the instance endpoint, for both commands before and after refresh.

BLOCKING: 1

Reviewed head cfa9e3e4c5 at 2026-11-10T18:42:53Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head cfa9e3e4c5bf05521e8d5381a37d3c96cc51d091. - **Medium** `src/config/fjord_scope.rs:11`: **Invariant: named-profile failures must suppress provider bodies across every request path** (standards 11 and 18). Both `instances list` and `instances use` call `fetch_listing_once`, which also fetches Commons. When `/api/v1/me/commons` returns a 403 or 503, `fetch_commons` includes the response body in its error, and `settle_commons` prints that error under `--debug` before this wrapper can redact it. A normal Commons outage can therefore expose private provider diagnostics in terminal output or captured logs, including after a refresh. This belongs in this PR because named-session error redaction is explicitly promised. Pass the profile redaction policy into the Commons settlement path and suppress bodies before logging. Extend `fjord_profile_listing_errors.rs` to fail the Commons endpoint as well as the instance endpoint, for both commands before and after refresh. BLOCKING: 1 --- Reviewed head cfa9e3e4c5bf05521e8d5381a37d3c96cc51d091 at 2026-11-10T18:42:53Z by codex exec (read-only sandbox).
Split profile helpers by integration test usage
All checks were successful
ci / check (pull_request) Successful in 15m44s
ci / coverage (pull_request) Successful in 4m17s
ci / live-e2e (pull_request) Successful in 4m39s
f8f4a26ef3
gerri approved these changes 2026-11-10 18:58:33 +00:00
gerri left a comment

Automated Codex review (read-only) of head f8f4a26ef3.

No confirmed correctness, security, or failure-path findings in the diff against STANDARDS.md. The documented step 2b-ii deferrals remain unchanged. Reviewed surrounding code; no tests run in the read-only sandbox.

BLOCKING: 0

Reviewed head f8f4a26ef3 at 2026-11-10T18:58:32Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head f8f4a26ef383869ed2221f2f191546fe2992a573. No confirmed correctness, security, or failure-path findings in the diff against STANDARDS.md. The documented step 2b-ii deferrals remain unchanged. Reviewed surrounding code; no tests run in the read-only sandbox. BLOCKING: 0 --- Reviewed head f8f4a26ef383869ed2221f2f191546fe2992a573 at 2026-11-10T18:58:32Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.