Exchange Check (RFC 8693 token exchange, subject-token read, Authorization injection, 401/403/5xx) #24
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lab/authz-bridge!24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/exchange-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #15
Implements the Exchange Flow
Check(machine tokens). A service account presents its Kanidm API token; the Bridge exchanges it for OAuth2 tokens via the RFC 8693 grant and hands the exchanged token to the backend.What it does
internal/serve/exchange.go(new) — the real:8084gRPCext_authzCheck, replacing the build-surface stub:403;secretReady=false/ no exchange section / no token endpoint →5xx(ADR 0011 fail-closed).header/prefix/tokenType(defaultsAuthorization/Bearer/access_token, matching theTokenExchangeSubjectTokenAPI defaults); missing or malformed (wrong prefix / empty token) →401. The token is opaque — forwarded, not validated (the token endpoint validates it).audience= the App's ownclientID, the policy's scopes,subject_token_typefrom config.access_tokenasAuthorization: Bearer <token>(overwrite) andheaders_to_removethe incoming subject-token header (the subject token is consumed, not forwarded).errorfield, or noaccess_token) or an unreachable token endpoint →5xx. A failed exchange never mis-authorizes.internal/serve/serve.go—exchangeServicegains anhttpClient; the Exchange stubCheckandcheckStubare removed (the callback stub remains until its ticket).Notes
internal/serve/exchange_test.go) cover all 5 acceptance criteria against a token-endpoint double that records the received form (assertinggrant_type,client_id,subject_token,subject_token_type,audience,scope, and thatclient_secretis absent), plus the 401/403/5xx gates and the configured header/prefix/type path.Review
Two-axis review (Standards + Spec): no hard standard violations; the principal smells are the repo's accepted per-flow parallelism (mirroring
oidc.go). All 5 acceptance criteria + the ADR 0011 status model are met; no scope creep.Verification
GOTOOLCHAIN=go1.26.0 make lint— 0 issues.GOTOOLCHAIN=go1.26.0 make test— all packages green (serve 89.3% coverage).