Files
archie/internal/app
sam 79f521b65b feat(webui): let a person sign in and act as themselves
The last gap in the identity boundary: enabling a provider used to lock browsers
out, because nothing could turn a sign-in into the credential the dashboard already
verifies. Now a browser completes the authorization code flow with PKCE and the
identity reaching the request context is the person who signed in.

The audience is requested AT THE AUTHORIZATION ENDPOINT, not only at the token
endpoint. Infra measured that a provider asked otherwise returns the audience empty,
and this dashboard then refuses a perfectly valid token -- a failure that reads as a
signing fault and is actually a missing query parameter. A test asserts the
parameter is present, so it cannot quietly go missing.

The flow is the libraries': discovery, the code exchange, PKCE generation and the
challenge transformation are go-oidc and x/oauth2, so archie writes no protocol. The
token returned by the exchange is verified through the SAME Verifier a presented
token goes through, and the identity is then resolved through the same rule -- one
Resolve now shared by Authenticate and the callback, so a browser sign-in cannot be
accepted on terms a presented token would be refused on.

Archie still issues no session. The callback stores the PROVIDER's token in an
HttpOnly cookie and every later request re-verifies it, so what archie holds cannot
outlive the provider's own decision. The callback checks the state it issued, and
expires the state and PKCE verifier cookies on use.

The sign-in routes mount on the bypass mux because they are how a caller becomes
authenticated; gating them behind the credential they obtain would make signing in
impossible. The client secret is never a flag: -oidc-client-secret-env names the
environment variable holding it, so it cannot reach a process listing or a log line.
No client id means no sign-in route and token verification is unaffected, which is
what an agent-only deployment wants.

Evidence, produced by driv·ng the flow rather than the seam:
internal/webui/api_tasks_actor_test.go's TestBrowserSignInRecordsTheSignedInPerson
walks sign-in -> callback -> cookie -> action and asserts the recorded actor is the
signed-in person with human_approved. TestCallbackRefusesAMismatchedState asserts a
replayed state is refused before any credential is verified.
internal/infrastructure/oidc/flow_test.go runs the real flow against a test
provider's own authorize and token endpoints, asserting the audience parameter, the
PKCE challenge, a successful exchange, and a refused wrong verifier.

Verified: task check exit 0 on this tree.
2026-09-22 14:59:03 +10:00
..