fix(oidc): OidcVerify routes through UserProvisioningService — invariants restored (#90) #113

Merged
amiryahaya merged 1 commit from fix/oidc-verify-invariants into main 2026-11-08 04:50:44 +01:00
Owner

Closes #90 (M2-audit P0 — the one sign-in surface the M1 fixes never reached).

The bug

/api/auth/oidc/verify's registration branch hand-rolled provisioning: suspended accounts could be linked via any pending invitation (re-entry credential for banned users), the invite claim was check-then-write (double-grant window), TenantId was never granted (invited users landed in no_workspace), and admins minted sessions with no MFA gate.

The fix

The registration branch builds an InviteeIdentity and calls ProvisionInviteeAsync (the shared path — suspended rejection, INV-03 binding, atomic Pending→Accepted claim, TenantId grant via ExecuteUpdate), then applies the SAME admin MFA gate as the existing-login branch: admins with TOTP → mfa-pending session; without TOTP → full session scoped to TOTP setup. Registration responses now carry mfa_required/totp_setup_required like the login path.

Verification

TDD: 4 invariant tests first — RED ×4 (suspended link accepted + invite burned; concurrent accept granted 2 seats from one invitation; TenantId missing; admin MFA skipped) — then migrated.

One test re-scoped during self-review: ConcurrentAccept's HTTP race outcome varies by interleaving on the SQLite shared-connection harness (all DbContexts interleave on one connection); it now pins the INVARIANT (≤1 seat from one invitation, verified via diagnostic dump) instead of the race outcome.

Suite 916 / 0 failed / 39 skipped (Release ×2 + Debug) · coverage gate 86.48% ≥ 80.

Closes #90 (M2-audit P0 — the one sign-in surface the M1 fixes never reached). ## The bug /api/auth/oidc/verify's registration branch hand-rolled provisioning: suspended accounts could be linked via any pending invitation (re-entry credential for banned users), the invite claim was check-then-write (double-grant window), TenantId was never granted (invited users landed in no_workspace), and admins minted sessions with no MFA gate. ## The fix The registration branch builds an InviteeIdentity and calls ProvisionInviteeAsync (the shared path — suspended rejection, INV-03 binding, atomic Pending→Accepted claim, TenantId grant via ExecuteUpdate), then applies the SAME admin MFA gate as the existing-login branch: admins with TOTP → mfa-pending session; without TOTP → full session scoped to TOTP setup. Registration responses now carry mfa_required/totp_setup_required like the login path. ## Verification TDD: 4 invariant tests first — RED ×4 (suspended link accepted + invite burned; concurrent accept granted 2 seats from one invitation; TenantId missing; admin MFA skipped) — then migrated. One test re-scoped during self-review: ConcurrentAccept's HTTP race outcome varies by interleaving on the SQLite shared-connection harness (all DbContexts interleave on one connection); it now pins the INVARIANT (≤1 seat from one invitation, verified via diagnostic dump) instead of the race outcome. Suite 916 / 0 failed / 39 skipped (Release ×2 + Debug) · coverage gate 86.48% ≥ 80.
fix(m2m): OidcVerify routes through UserProvisioningService — suspended link, atomic claim, TenantId grant, admin MFA gate (#90)
All checks were successful
Security CI / security-scan (pull_request) Successful in 2m50s
API CI / build-and-test (pull_request) Successful in 3m55s
2c5a69be48
The /api/auth/oidc/verify registration branch was the last hand-rolled
provisioning path — the M1.5 close audit flagged it (#90, P0): suspended
accounts could be linked via any pending invite (re-entry credential for
banned users), the invite claim was check-then-write (double-grant
window), TenantId was never granted (ACC-02 no_workspace), and admins
minted sessions with no MFA gate.

Fix: the registration branch builds an InviteeIdentity and calls
ProvisionInviteeAsync (the shared path — suspended rejection, INV-03
binding, atomic Pending→Accepted claim, TenantId grant via
ExecuteUpdate), then applies the SAME admin MFA gate as the
existing-login branch: admins with TOTP → mfa-pending session; without
TOTP → full session scoped to TOTP setup. Registration responses now
carry mfa_required/totp_setup_required like the login path.

TDD: 4 invariant tests first — RED ×4 (suspended link accepted +
invite burned; concurrent accept granted 2 seats from one invitation;
TenantId missing; admin MFA skipped) — then migrated. One test re-scoped
during self-review: ConcurrentAccept's HTTP race outcome varies by
interleaving on the SQLite shared-connection harness (all DbContexts
interleave on one connection); it now pins the INVARIANT (≤1 seat from
one invitation, verified via diagnostic dump) instead of the race
outcome. Suite 916 / 0 failed / 39 skipped (Release ×2 + Debug); gate
86.48% ≥ 80.
Sign in to join this conversation.
No description provided.