Skip to content

[M2.2c4a] Enforce session origin and CSRF boundaries - #48

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2c4a-http-session-guards
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2c4a-http-session-guards

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

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.

  • M2.2c4a acceptance criteria documented and met
  • Relevant tests, lint and typecheck pass locally
  • No new shell invocation or secret exposure path
  • No new business state mutation; session activity and throttle counters reuse existing stores
  • Threat model and plan updated

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2c3b-smtp-delivery branch from 6fdde0c to 21c05e5 Compare November 5, 2026 12:15
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.2c3b-smtp-delivery to main November 5, 2026 12:15
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2c4a-http-session-guards branch from 305870b to 0284c73 Compare November 5, 2026 12:16
@samuelmbabhazi
samuelmbabhazi merged commit 50d466a into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2c4a-http-session-guards branch November 5, 2026 12:16
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
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