Repository navigation
[M2.2b3] Serialize identity and credential mutations - #43
Merged
Merged
Conversation
6 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2b2-identity-schema
branch
from
November 5, 2026 12:11
035182a to
2090cbd
Compare
samuelmbabhazi
changed the base branch from
feat/m2.2b2-identity-schema
to
main
November 5, 2026 12:13
samuelmbabhazi
force-pushed
the
feat/m2.2b3-identity-store
branch
from
November 5, 2026 12:13
2a98306 to
6432448
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.2c1, part of #21. Depends on #43; base `feat/m2.2b3-identity-store`. ## What changed and why Add account and session commands behind application ports. Signup preserves existing credentials, verification/reset credentials are single-use, login rotates the presented session, and password reset invalidates all older sessions and reset links. Password proof is checked again against the user's security version under a row lock to prevent a concurrent reset from authorizing a stale login. Every command mutation publishes an identity event in the same database transaction. Session authentication verifies account status, security version, idle/absolute expiry and a session-bound CSRF hash using a timing-safe comparison. SMTP delivery, request limits, public HTTP endpoints and MFA are intentionally separate remaining plan items; these commands are not exposed over HTTP in this PR. ## Validation - Twenty-five real PostgreSQL integration tests pass, including eight complete command-flow tests. - Coverage includes mailbox verification, duplicate signup, expired/wrong-purpose links, concurrent reset attempts, session rotation, CSRF binding, logout idempotency, reset-versus-login races, generic credential rejection and injected audit failures. - Workspace lint, types, TypeScript tests and builds pass. ## Security considerations Credential values remain wrapped until hashing, storage or the mail port. Password hashing and mail delivery occur outside database transactions. A mail delivery failure leaves an unverified account eligible for the explicit resend flow; it grants no session. Request throttling and production delivery must land before exposing the commands publicly. No new shell invocation or agent action is introduced. ## Checklist - [x] M2.2c1 acceptance checked; M2.2c remains open - [x] Lint, types, tests and builds pass - [x] Concurrency, replay, expiry and audit-failure tests added - [x] No new secret logging or shell invocation - [x] State changes audited atomically - [x] Remaining HTTP, delivery, throttling and MFA work explicit in PLAN
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.
Task
M2.2b3, part of #21. Base:
feat/m2.2b2-identity-schema; follows the identity schema PR.What changed and why
Add the identity storage port, redacting domain records and Prisma adapter. Per-user row locks serialize sensitive mutations. Password changes increment the security version and revoke sessions and reset credentials; single-use token claims use conditional updates. Session activity advances monotonically across overlapping requests and cannot revive expired, revoked, disabled-owner or stale-version sessions.
Commands can share the transaction/audit boundary from #41. Driver errors from command transactions are replaced with an opaque availability error to keep bound data out of HTTP logs. A reusable integration fixture owns its PostgreSQL container, temporary KEK, Nest application and cleanup.
Validation
Security considerations
No HTTP endpoint is exposed yet. Application handlers must perform mutations and publish their events inside
transactionorwithUserLock; this PR supplies and tests that boundary. Password hashes returned by repositories are wrapped inSecret. Session activity is authentication telemetry, not a separate domain command. No new shell invocation or dynamic SQL identifier is introduced.Checklist