Skip to content

[M2.2d2a] Require atomic second-factor login proofs - #54

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d2a-mfa-login-proof
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d2a-mfa-login-proof

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Login now checks the account's active second factor under the same user lock that creates the session. TOTP counters and recovery codes are consumed atomically; missing, invalid, ambiguous or replayed proofs cannot grant a session. Recovery use is audited, and audit/session failure rolls proof consumption back.

The envelope adapter binds each encrypted seed to its user. A shared authenticated-rotation command increments the security version, revokes older sessions and reset links, and issues a fresh session in one audited transaction. Password reset preserves MFA. Enrollment management and HTTP proof DTOs follow in M2.2d2b/d3.

Validation: API lint/typecheck, 94 unit tests and 56 PostgreSQL/TLS SMTP integration tests pass. Five new tests cover missing/replayed factors, concurrent TOTP/recovery use, audit rollback, password reset preserving MFA, atomic rotation and stale security context.

Security: no full session exists before second-factor proof. Decrypted seeds remain wrapped and temporary buffers are cleared; crypto/storage failures are opaque. No new dependency or transport. Stacked on #53; no merge requested.

  • M2.2d2a criteria met
  • Real PostgreSQL concurrency and rollback tests pass
  • Privilege changes invalidate previous session versions
  • Plan updated; no new secret exposure or shell invocation

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d1-mfa-storage branch from 7ac6663 to 9304f78 Compare November 5, 2026 12:32
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2d1-mfa-storage to main November 5, 2026 12:32
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d2a-mfa-login-proof branch from 3402961 to 84d3e48 Compare November 5, 2026 12:32
@samuelmbabhazi
samuelmbabhazi merged commit 5a4ece0 into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d2a-mfa-login-proof branch November 5, 2026 12:33
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Users can now stage and activate TOTP enrollment, disable MFA, and
regenerate recovery codes through audited application commands. Every
operation rechecks the current password and session security version;
disablement and recovery replacement additionally consume a valid
factor. An active seed cannot be overwritten by another setup request.

Activation, disablement and recovery replacement atomically rotate all
sessions and reset links, returning a fresh session. Recovery values are
shown only in the command result and stay wrapped until the eventual
HTTP delivery boundary. Failed audit or rotation rolls back MFA state
and proof consumption. Public endpoints follow in M2.2d3.

Validation: API lint/typecheck and 60 real PostgreSQL/TLS SMTP
integration tests pass. Four new tests cover password reauthentication,
simultaneous activation, expiry, a racing password change, code
regeneration invalidating old codes, protected disablement, session
revocation and audit rollback. API unit tests also pass.

Security: current security version is checked again under the user lock
after expensive password work. No seed/code appears in audit metadata;
responses use Secret wrappers. No new dependency, migration or external
transport. Stacked on #54; no merge requested.

- [x] M2.2d2b and MFA application commands complete
- [x] Real database concurrency and rollback tests pass
- [x] State transitions and recovery use audited
- [x] Plan/spec updated; no new secret exposure or shell invocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant