Repository navigation
[M2.2c4a] Enforce session origin and CSRF boundaries - #48
Merged
Merged
Conversation
5 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2c3b-smtp-delivery
branch
from
November 5, 2026 12:15
6fdde0c to
21c05e5
Compare
samuelmbabhazi
changed the base branch from
feat/m2.2c3b-smtp-delivery
to
main
November 5, 2026 12:15
samuelmbabhazi
force-pushed
the
feat/m2.2c4a-http-session-guards
branch
from
November 5, 2026 12:16
305870b to
0284c73
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
The account/session commands are now reachable through eight validated HTTP endpoints: signup, verification request/claim, password-reset request/claim, login, session lookup and logout. The identity module registers default-deny authentication and persistent rate guards globally; health remains explicitly public. Login returns only account metadata and sets the session/CSRF cookies. Signup and mail requests return the same empty 202 for existing/missing accounts. Missing SMTP configuration rejects mail-dependent commands before account creation. The durable email worker starts after the queue and only when SMTP is configured. Responses are no-store, bodies are capped at 16 KiB, and proxy trust defaults to none (explicit loopback option). Validation: all 41 PostgreSQL/TLS SMTP integration tests pass, including a full HTTP signup → email delivery → verification → session rotation → password reset → logout flow. Additional HTTP checks exercise duplicate/replayed codes, missing CSRF, generic account responses, quota headers, oversized/unknown fields, audit rollback and missing SMTP. Workspace TS lint/typechecks/tests, API production build, Go tests and protobuf lint pass. OpenAPI and the typed client were regenerated. Security: no credential in response JSON or navigation URLs; auth failures do not expose account existence. Protected routes require session/CSRF; credentials are wrapped at the boundary. The idempotency header is tracked separately in M2.2c4c, MFA/tokens in M2.2d and the browser UI in M2.2e. This PR is stacked on #48; no merge requested. - [x] M2.2c4b acceptance criteria met - [x] New HTTP behavior tested against real PostgreSQL and local TLS SMTP - [x] State changes audited atomically by existing commands - [x] Generated contract, spec, plan and example configuration updated - [x] No new shell invocation or secret exposure path
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.
Browser session guards now reject unauthenticated requests by default and require both an exact configured Origin and a session-bound CSRF header for mutations. Explicit anonymous routes still enforce Origin on writes. HTTPS cookies are host-bound, Secure and SameSite=Strict; only the CSRF cookie is JavaScript-readable.
The rate guard applies the persisted quotas before DTO processing, normalizes account subjects, and returns Retry-After and quota metadata. Duplicate credentials and bearer-to-cookie fallback fail closed. Global registration and account endpoints follow in M2.2c4b.
Validation: API lint, strict typecheck and all 92 unit tests pass, including eight new HTTP/cookie boundary tests. Tests cover cross-site requests, missing or mismatched CSRF, duplicate cookies, untrusted forwarded IPs and quota responses. No database migration or generated-contract change in this slice.
Security: the CSRF header joins the logging redaction list. No raw credentials are logged; authentication reuses the validated session service. This PR is stacked on #47; do not merge automatically.