Repository navigation
sso: identity by (issuer, subject); fresh, per-app sign-in - #7
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process: ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵🧪 PR contains tests⚡ Recommended focus areas for reviewBlocked Step-up Every SSO login now receives a pending session, but Advisory only: this comment never gates the pull request. |
Security review - clearedDetail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kyguard-server-7, where it is readable by the operator and expires seven days after the last post. gpt-6.1-sol using security-audit on behalf of Yoshi |
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. gpt-6.1-sol using security-audit on behalf of Yoshi |
cd927d9 to
e6e0cdd
Compare
|
Fixed in
Checked: 🤖 Generated with Claude Code |
Account identity is now the verified token's (iss, sub) (spec §7.2): users.sso_issuer with a unique index, sessions record their issuer, and both back-channel logout fences are keyed by issuer, so the same sid or subject from another issuer is untouched. SCIM accounts take KY_SCIM_ISSUER (default KY_KYSIGNON_ISSUER) and adoption matches on both halves. Add the generic OIDC login and callback routes. Both providers send max_age=0 and their MFA acr set as acr_values, parse auth_time, amr and acr, refuse an auth_time missing or older than 120 seconds, and record whether the token asserted MFA for the step-up PR to use. The role now comes only from the per-app roles claim, recomputed at every sign-in; the IdP-wide role fallback is gone. SCIM never grants admin and KY_SCIM_ALLOW_ADMIN is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of cd927d9: when adoption lost a race, the reload by row ID accepted the row even if a concurrent SCIM externalId correction had changed its subject, so a session could be issued for an account that no longer matched the verified token. The reload now must still carry the token's issuer and subject and the signing-in provider, else 409. Startup now refuses a database holding SSO subjects without an issuer (pre-migration-13 rows), which (issuer, subject) lookups cannot reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SCIM refused nothing when no issuer was configured, so a create with an externalId stored an unissued identity and the next start refused. It now refuses an externalId until KY_SCIM_ISSUER or KY_KYSIGNON_ISSUER is set, and a row created before that takes the issuer with its first subject. Rows from before migration 13 may share a subject across providers and all get an empty issuer, so the unique identity index now skips unissued rows. The migration applies; the start check names the repair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e6e0cdd to
c2eb117
Compare
|
Guide findings fixed in c2eb117:
|
Sessions from before migration 13 get an empty issuer, so neither issuer-keyed back-channel logout fence reaches them. The migration now deletes them; local break-glass sessions stay (security review P2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Security P2 (legacy SSO sessions) fixed in 8f67570: migration 13 deletes sessions with an |
Resolves CHANGELOG and DECISIONS: both sides kept; the crypto stack's decisions keep their numbers under their own heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An SSO callback now issues only a pending session that lasts five minutes. The session middleware refuses a pending session everywhere except who-am-I and logout, so SSO users can do nothing else until the TOTP step-up exchange (#17) lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Security P1 fixed in 9220dd7: SSO sign-in fails closed until local step-up. The callback issues a 5-minute pending session, which the session middleware accepts only for who-am-I and logout. SSO users can't get further until #17's TOTP exchange lands. Regression test |
…d/stepup #7 (9220dd7) made the SSO callback issue a pending session that only who-am-I and logout accept. Conflicts resolved in favour of stepup: IssuePendingSession, ExchangePending and pendingAllowed with /api/auth/stepup/* stay. #7's IssueSSOSession, which stepup no longer calls and which would issue an active SSO session here, is dropped. TestOIDCSignInIsPendingUntilStepUp now expects stepup's 403 stepup_required instead of #7's 401. New TestOIDCSignInStepsUpToActive signs in through the generic OIDC routes, enrolls on the pending session, then steps up again with a code, both through to an active session (the #7 Guide note's integration test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/DECISIONS.md
…t-chain Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… into kyguard/intents Drops audit-chain's "scope of this PR" decision 19: this PR builds what it deferred. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to kyguard/restore Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-login Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…) into kyguard/web-restepup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire On "Blocked step-up": #7 fails closed on purpose. On this PR alone an SSO sign-in gets a pending session that reaches only
No routes were added to #7. |
In one line: An account is now identified by the verified token's
(issuer, subject), every sign-in demands a fresh IdP login, and admin comes only from the per-approlesclaim.What changed
users.sso_issuerwith a unique(sso_issuer, sso_subject)index; sessions record their issuer; both back-channel logout fences (sso_logouts,sso_subject_logouts) are keyed by issuer (migration 13). Two issuers with the same subject are two users./api/sso/oidc/loginand/callback(shared handler with KySignOn).max_age=0and the profile's MFA acr set (urn:kysignon:acr:mfa;KY_OIDC_MFA_ACRSfor OIDC); the callback parsesauth_time,amr,acrand refusesauth_timemissing, >120 s old or in the future. The MFA assertion (amrhasmfaoracrin the set) is recorded for the next PR.adminonly if per-approlescontainsadmin, recomputed and written at every sign-in; the IdP-widerolefallback is gone.KY_SCIM_ALLOW_ADMINremoved; SCIM rows takeKY_SCIM_ISSUER(defaultKY_KYSIGNON_ISSUER) and adoption matches on issuer and subject.Review this
GetUserBySSO,EndSSOSession,EndSSOSubjectand the fence check: issuer is now in every identity and fence query.ssoAccount: lookup, adoption, provisioning and role recompute.checkRole(see Decided for you).Checked:
go test -race ./...SQLite (K81) and PostgreSQL 17 (K83) exit 0 at this head's parent and again after rebase on #3's fixes; smoke test passes. Mutations (each fails its test): role fallback restored →TestSignInRoleComesOnlyFromPerAppRoles; freshness check skipped →TestStaleAuthTimeIsRefused; lookup ignoring issuer, and sid logout ignoring issuer →TestIssuerIsPartOfTheIdentity; SCIM grant allowed →TestSCIMNeverGrantsAdmin;otpcounted as MFA →TestMFAAssertionRule;max_agedropped →TestAuthorizationRequestAsksForFreshMFA.Not checked: the Compose replica e2e locally (Major's Docker address pool is exhausted); CI runs it.
Decided for you
docs/DECISIONS.md9).KY_SCIM_ISSUERdefaults to the KySignOn issuer (DECISIONS 10); a futureauth_timeis refused (11); the fence tables are replaced, not converted (12).You need to: review; hold unmerged. Stacked on #3.
§13 Phase 0 items: from "Identity: …" —
users.sso_issuer; issuer-awareAdoptSCIMUser; generic OIDC routes;max_age=0,auth_time,amr,acr; MFA assertion rule; per-app admin without fallback; SCIM admin refusal; logout fences by issuer (the check-after-insert exchange path and its concurrent test come with step-up). Acceptance: 7 (auth_time), 8, 10.Review fixes (hawthorn fix-auth)
externalIdwhile no issuer is set, and a row created before then takes the issuer with its first subject.(sso_issuer, sso_subject)index skips unissued rows, so migration 13 applies over legacy cross-provider collisions. The start check names the repair (DECISIONS 12).TestSCIMNeverStoresASubjectWithoutAnIssuersso_issuerTestMigration13KeepsLegacySubjectCollisionsDELETETestMigration13DropsSessionsNoLogoutCouldEndChecked at 8f67570: race and FIPS suites on SQLite (k80) and PostgreSQL 17 (k82), exit 0.
Review fix (hawthorn fix-pr7): SSO sign-in fails closed until local step-up
sessions.stage, migration 12 on auth: break-glass accounts with mandatory TOTP #3) that lastsauth.PendingTTL(5 min).AuthenticateRequestrefuses a pending session everywhere exceptGET /api/auth/meandPOST /api/auth/logout. auth: pending SSO sessions and TOTP step-up (§7.3) #17 replaces this with its full pending session and TOTP exchange.IssueSSOSession,pendingAllowedand the stage check inAuthenticateRequest.active(the old behaviour)TestOIDCSignInIsPendingUntilStepUpstageNo existing test needed changing; the other SSO tests use only who-am-I and logout.
Checked at 9220dd7: gofmt, vet, build, race and FIPS suites on SQLite (Major, kjob fallback; every K host was busy, exit 0) and PostgreSQL 17 (k83, exit 0). Web code is unchanged.
Round 4 (hawthorn): main merged
origin/main(auth: break-glass accounts with mandatory TOTP #3–kyguard-cli: init, trust, import, enroll and sign (§3.2) #6 and the badge fix). The only conflict wasCHANGELOG.md, which is additive, so both sides are kept. No code was changed and no routes were added (step-up stays in auth: pending SSO sessions and TOTP step-up (§7.3) #17).go vet,go build, andgo test -race -count=1 -p 2 ./...plus the same underGODEBUG=fips140=on. SQLite passed (k82, exit 0). PostgreSQL 17 passed (Major, own postgres:17-alpine container, exit 0).🤖 Generated with Claude Code