feat(identity): ADR-012 — step-up trusts IdP-asserted authentication context (amr) #129

Merged
amiryahaya merged 1 commit from feat/adr012-amr-stepup into main 2026-11-09 07:59:18 +01:00
Owner

Implements the ADR-012 code leg (the one passkey-era gap flagged in the specs update, PR #123): admin step-up now trusts the IdP's word about HOW a user authenticated.

Behavior: an admin whose id_token carries an IdP-asserted MFA factor (amr: otp/otp_sms/mfa/pk/webauthn) gets a FULL session from both OIDC surfaces — mfa_required/totp_setup_required stay false. Under the passkey realm policy (NFR-02), the passkey ceremony at Zitadel IS the step-up; demanding Drive-side TOTP enrollment on top was wrong. Password-only amr, bare user presence and hwk possession do NOT satisfy step-up; amr-less logins keep the legacy gates unchanged (TotpEnabled → mfa-pending, else setup-scoped). The wallet Authenticate path (no id_token) is untouched.

Implementation:

  • OidcClaims carries amr/auth_time; OidcTokenValidator.HasIdpMfaFactor + IdpMfaAmrValues (the factor set is one constant, realm-policy evolution touches one place)
  • MapInboundClaims=false on the JWT handler — claim types stay IdP-native (sub/amr/auth_time are not renamed into long ClaimTypes namespaces); the existing sub/email fallbacks retained, all OIDC suites green
  • Both gate copies (OidcVerify login + registration branches; OidcCallback) apply IdP-factor-first ordering
  • FakeIdpServer mints amr/auth_time on both the direct-token and code-flow paths — the harness can now express 'admin authenticated with a passkey at the IdP'

Tests: 5 new (Adr012AmrStepUpTests): passkey-at-IdP → full session (was setup-scoped — RED), OTP-at-IdP for a TotpEnabled admin → full session (was mfa-pending — RED), password-only stays setup-scoped (control), no-amr stays mfa-pending (control), and the callback-path passkey redirect asserts both flags false. Suite 958/0/39 (Release+Debug), coverage 87.97%. Closes the ADR-012 code leg of task 2.2; realm config (platform-admins realm, email-fallback disabled) remains the staging bring-up step.

Implements the ADR-012 code leg (the one passkey-era gap flagged in the specs update, PR #123): admin step-up now trusts the IdP's word about HOW a user authenticated. **Behavior:** an admin whose id_token carries an IdP-asserted MFA factor (`amr`: otp/otp_sms/mfa/pk/webauthn) gets a FULL session from both OIDC surfaces — `mfa_required`/`totp_setup_required` stay false. Under the passkey realm policy (NFR-02), the passkey ceremony at Zitadel IS the step-up; demanding Drive-side TOTP enrollment on top was wrong. Password-only amr, bare `user` presence and `hwk` possession do NOT satisfy step-up; amr-less logins keep the legacy gates unchanged (TotpEnabled → mfa-pending, else setup-scoped). The wallet `Authenticate` path (no id_token) is untouched. **Implementation:** - `OidcClaims` carries `amr`/`auth_time`; `OidcTokenValidator.HasIdpMfaFactor` + `IdpMfaAmrValues` (the factor set is one constant, realm-policy evolution touches one place) - **MapInboundClaims=false** on the JWT handler — claim types stay IdP-native (`sub`/`amr`/`auth_time` are not renamed into long ClaimTypes namespaces); the existing sub/email fallbacks retained, all OIDC suites green - Both gate copies (OidcVerify login + registration branches; OidcCallback) apply IdP-factor-first ordering - FakeIdpServer mints amr/auth_time on both the direct-token and code-flow paths — the harness can now express 'admin authenticated with a passkey at the IdP' **Tests:** 5 new (Adr012AmrStepUpTests): passkey-at-IdP → full session (was setup-scoped — RED), OTP-at-IdP for a TotpEnabled admin → full session (was mfa-pending — RED), password-only stays setup-scoped (control), no-amr stays mfa-pending (control), and the callback-path passkey redirect asserts both flags false. Suite 958/0/39 (Release+Debug), coverage 87.97%. Closes the ADR-012 code leg of task 2.2; realm config (platform-admins realm, email-fallback disabled) remains the staging bring-up step.
feat(identity): ADR-012 — step-up trusts IdP-asserted authentication context (amr)
All checks were successful
API CI / build-and-test (pull_request) Successful in 14m38s
Security CI / security-scan (pull_request) Successful in 4m21s
5e13a9b036
An admin whose id_token carries an IdP-asserted MFA factor (amr: otp/
otp_sms/mfa/pk/webauthn) satisfies step-up at the IdP — Drive mints a
FULL session instead of demanding Drive-side TOTP. Password-only amr
(pwd), bare user-presence (user) and hardware-possession (hwk) do NOT
count; amr-less logins keep the legacy gates (TotpEnabled → mfa-pending,
else setup-scoped). Wallet Authenticate (no id_token) untouched.

- OidcClaims carries amr/auth_time; OidcTokenValidator exposes
  HasIdpMfaFactor + the IdpMfaAmrValues set
- JwtSecurityTokenHandler now runs with MapInboundClaims=false — claim
  types stay IdP-native (sub/amr/auth_time are not renamed into long
  ClaimTypes namespaces); existing sub/email fallbacks retained
- Both gate copies (OidcVerify login + registration branches,
  OidcCallback) apply IdP-factor-first ordering
- FakeIdpServer mints amr/auth_time on both paths (direct token + code
  flow PendingToken)

5 new tests (Adr012AmrStepUpTests): passkey-at-IdP full session, OTP-at-IdP
for TotpEnabled admin full session, password-only stays setup-scoped,
no-amr stays mfa-pending, callback-path passkey redirect asserts. Suite
958/0/39 Release+Debug, coverage 87.97%.
Sign in to join this conversation.
No description provided.