Repository navigation
Track A: harden OIDC SSO (PKCE, issuer-bound identity, source-scoped roles) - #511
Merged
Merged
Conversation
- Add server-side Authorization Code + S256 PKCE, nonce, and one bounded transaction consumed atomically before code exchange; replay is refused. - Pin issuer and signing algorithms; verify signature, iss, aud, exp, nonce. - Return a one-time exchange code instead of a session token in the URL; add POST /api/v1/auth/oidc/exchange with IP binding and no-store. - Resolve users by (issuer, subject); never auto-bind issuer-less legacy rows or grant implicit admin; keep local break-glass recovery. - Reconcile only source=oidc roles transactionally before session issue via new db.SetUserRolesBySource; preserve local/admin grants, fail closed on privileged provenance conflicts, rotate sessions on sign-in. - Add frozen Track B Phase 0 hooks (BootstrapAudit, SessionSnapshot, SessionValidator) and the production SessionValidator implementation. - Add redacted OIDC audit events, canonical Carbon login error/lockout states, config defaults, ADRs 0023-0026, knowledge concept and owned fixtures.
…usal fixtures - Make extra_claims_url enrichment fill-only with protected identity and role-claim keys, so it cannot overwrite verified claims or elevate roles; bound the response body and check Close errors. - Fix new-code lint findings: checked deferred store.Close and QF1008 key. - Add harmless fixtures for invalid issuer, wrong audience, wrong/missing nonce, expired token, signature failure, JWKS rollover and extra-claims injection, plus a bounded-response assertion. - Document in ADR 0025 that ValidateSession's per-request DB role re-read is the security boundary after split reconciliation/session issue.
# Conflicts: # knowledge/decisions/adrs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tenant-independent Track A authentication/SSO hardening from the reviewed
plan gate (
security-runtime-plans/auth-sso.md, G1–G11).No live IdP tenant, credentials, deploy or release involved.
Protocol
nonce, and a bounded in-memorytransaction holding state+nonce+verifier consumed with a single locked compare-and-delete
before code exchange. Replay/concurrent callbacks are refused and never call the IdP
token endpoint.
HS256 only by explicit operator choice), and
iss/aud/exp/signature/nonce validation.exchange code redeemed via
POST /api/v1/auth/oidc/exchange(Cache-Control: no-store).Identity and entitlement
(issuer, subject)with a new store lookup. A legacy issuer-less rowyields
link_required; no email/name auto-link, no implicit admin, no first-user admin fromSSO. Local break-glass admin and recovery key remain the recoverable path.
db.SetUserRolesBySourcereconciles onlysource=oidcroles in one transaction andpreserves local/admin grants. Absent groups default to revoke; no
keep_previous; privilegedraw claim names are refused without an explicit mapping; privileged provenance conflicts
refuse sign-in and are audited. Reconciliation precedes session issue and role loss revokes
all prior sessions.
Shared contracts and UI
internal/auth/hooks.go):BootstrapAudit,SessionSnapshot,SessionValidator, plus the production validator.Exact signatures match Track B B-00; no import cycle.
security_auditevents (issuer, subject hash, user ID, outcome, role-delta counts;never state/nonce/code/verifier/tokens/secrets).
?code=and maps?error=codes to fixed operator-safe messages.Verification (actual runs)
go test ./... -count=1— all packages pass, including new auth/db fixtures.go veton affected packages — clean.bun install --frozen-lockfile;bun run check(0 errors, 0 warnings);bun run test(279 pass, 0 fail).node ./node_modules/vite/bin/vite.js build— succeeded(
✓ built, adapter-static wrotebuild). Thescripts/web-build.shbash wrapper could notrun in this Windows harness (bash/WSL service unavailable), so its exact command was run
directly with a 2048 MB heap cap.
go run ./cmd/knowledge-lint -root . -fixthen without-fix— OK, 60 concepts,38/38 queries, indexes current. One pre-existing warning on
invariants/data-safety(verification date older than its file change) is unrelated to this change.
Owned local OIDC discovery fixtures cover PKCE/nonce/state parameters, cookie flags,
issuer+subject identity, no auto-bind, no implicit admin, raw privileged-name denial,
source-aware role preservation, one-time exchange, and the session validator contract.
No exploit testing and no live provider calls were performed.
Evidence limits / limitations
not verified; documentation-driven configuration support only.
and caps). Multi-controller deployments need a shared store in a later slice.
degraded health (plan D10/P5) and best-effort IdP logout (ADR 0026) remain follow-up slices.
auth.session_timeoutabsolute expiry remains.depend on them and will be rebased if needed.
Merge policy
Draft only. Independent review and CI are required. Do not merge from this lane.