Repository navigation
[M2.2d1] Persist encrypted MFA enrollment and proofs - #53
Merged
Merged
Conversation
samuelmbabhazi
force-pushed
the
feat/m2.2d1-mfa-storage
branch
from
November 4, 2026 11:36
364bd8c to
7ac6663
Compare
samuelmbabhazi
force-pushed
the
fix/m2.2c5-http-secret-boundaries
branch
from
November 4, 2026 11:36
507e9e2 to
42f35ba
Compare
4 tasks done
samuelmbabhazi
force-pushed
the
fix/m2.2c5-http-secret-boundaries
branch
from
November 5, 2026 12:31
42f35ba to
98423a7
Compare
samuelmbabhazi
changed the base branch from
fix/m2.2c5-http-secret-boundaries
to
main
November 5, 2026 12:31
samuelmbabhazi
force-pushed
the
feat/m2.2d1-mfa-storage
branch
from
November 5, 2026 12:32
7ac6663 to
9304f78
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
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. - [x] M2.2d2a criteria met - [x] Real PostgreSQL concurrency and rollback tests pass - [x] Privilege changes invalidate previous session versions - [x] Plan 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.
MFA persistence now keeps either an encrypted pending TOTP seed or an active seed. Pending enrollment lasts ten minutes, is tied to the account security version, and cannot activate after expiry, a password change or account disablement. An active seed cannot be overwritten by staging another enrollment.
TOTP counters only advance, recovery hashes are consumed once, and all mutations join the existing user transaction. Removing MFA cascades its recovery records. Schema constraints enforce paired fields, ciphertext bounds, counter range and enrollment lifetime. Commands/HTTP wiring follow in M2.2d2/d3.
Validation: API lint/typecheck and all 51 real PostgreSQL/TLS SMTP integration tests pass. Four new PostgreSQL tests cover encrypted round trips, expiry/version/disabled-account rejection, concurrent claims across connections, cascade cleanup, invalid hash batches and audit-failure rollback.
Security: raw seeds and recovery values never enter the new tables. The adapter only accepts ciphertext; envelope associated data binds it to the user. Application commands must hold the existing per-user lock. This PR introduces persistence only and does not yet enable MFA enrollment publicly. Stacked on #52; no merge requested.