Repository navigation
[M2.2d2a] Require atomic second-factor login proofs - #54
Merged
Merged
Conversation
4 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2d1-mfa-storage
branch
from
November 5, 2026 12:32
7ac6663 to
9304f78
Compare
samuelmbabhazi
force-pushed
the
feat/m2.2d2a-mfa-login-proof
branch
from
November 5, 2026 12:32
3402961 to
84d3e48
Compare
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
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.
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.