feat: Slice 4 — auth failure modes & token lifecycle hardening#14
Conversation
- GET /auth/me: expired/tampered/wrong-secret/empty/double-space/no-header/deleted-sub cases - POST /auth/login: both-fields-invalid 422, DB-unreachable 503, 415 body - Log events: auth.login.success fields, auth.login.failed must not contain plaintext email - e2e: tampered token -> /login with session-expired toast; unauthenticated -> silent redirect Closes #4 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…og, session-expired toast - requireAuth rejects 'Bearer abc' (double-space token) as Malformed Authorization header - login use-case logs SHA-256 hash of email, never plaintext - patient/doctor beforeLoad detects existing token and redirects with reason=session-expired - login page renders session-expired toast from ?reason=session-expired search param - login page shows per-field validation errors on 422 response Closes #4 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @itlamb's task in 3m 45s —— View job Review: Slice 4 — auth failure modes & token lifecycleVerdict: APPROVE (with non-blocking notes) This is a tight, well-scoped slice. It pins exactly the failure-mode polish that was missing on top of the auth groundwork from issues #1–#3, and the tests are appropriately external-behavior focused. Spec compliance vs. acceptance criteria
All hard acceptance criteria are met. Architecture findings✅ Layering is clean: route → use-case → infrastructure. No layer-skipping.
Security findings✅ Wrong-creds and unknown-email return byte-identical 401 bodies and emit the same Minor — none of these are blockers:
Test quality✅ All new tests assert observable behaviour (status, body, log lines via captured sink) — no implementation-coupling. Gaps, all minor:
Suggestions (non-blocking)
|
Summary
requireAuthnow correctly rejectsBearer abc(double-space token) asMalformed Authorization header(not justInvalid token)loginuse-case logs a SHA-256 hash of the email address on failure — never the plaintext emailbeforeLoadguards detect an existing (but invalid) token and redirect to/login?reason=session-expired?reason=session-expiredsearch param is presentissuesarray next to the offending fieldsTest plan
pnpm verifyclean (6 test files, 41 tests)pnpm test:e2e— tampered token → session-expired toast (requires running stack)pnpm test:e2e— unauthenticated → silent redirect (no toast)Closes #4
🤖 Generated with Claude Code