Skip to content

feat(auth): add current-user, CSRF-token, and logout endpoints - #27

Merged
rd-code-23 merged 1 commit into
mainfrom
feature/auth
Aug 19, 2026
Merged

rd-code-23 merged 1 commit into
mainfrom
feature/auth

Conversation

@rd-code-23

Copy link
Copy Markdown
Owner

What changed

  • add GET /auth/me for anonymous and authenticated auth-state hydration
  • add GET /auth/csrf-token backed by the server-side session
  • add CSRF-protected, idempotent POST /auth/logout
  • destroy the PostgreSQL session and clear the opaque session cookie on logout
  • apply synchronizer-token CSRF protection globally to unsafe HTTP methods
  • return only the current user’s public profile fields
  • add the documented csrf-sync dependency

Why

The browser needs a minimal API for discovering its current authentication state, protecting cookie-authenticated mutations, and safely ending a session.

Security behavior

  • CSRF tokens are stored in server-side session state and returned through a dedicated endpoint
  • clients must return the token in X-CSRF-Token
  • missing, invalid, and cross-session tokens return a safe 403 response
  • logout revokes CSRF state, destroys the session, and clears the cookie
  • provider identity fields, tokens, session contents, and secrets are not exposed

Validation

  • pnpm --filter @goforlift/api lint
  • pnpm --filter @goforlift/api typecheck
  • pnpm --filter @goforlift/api test — 42 tests passed
  • pnpm --filter @goforlift/api build
  • manually verified auth hydration, CSRF rejection, valid logout, and anonymous state after logout

Closes #10

@rd-code-23
rd-code-23 marked this pull request as ready for review August 19, 2026 04:12
@rd-code-23
rd-code-23 merged commit 00589f1 into main Aug 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auth][Phase 2] Add current-user, CSRF-token, and logout endpoints

1 participant