Public endpoints that bootstrap sessions: validates Firebase ID tokens, issues JWT access tokens, and refreshes access via HTTP-only cookie handshake.
Mounted before requireAuth in app.ts, so routers here must avoid trusting req.user until JWT verification completes.
| File | Responsibility |
|---|---|
authRouter.ts |
Route registration |
authController.ts |
verifyFirebaseToken, refreshAccessToken |
auth.schema.ts |
Validates inbound Firebase payloads |
- Uses
firebase.tsAdmin SDK (initialized inserver.ts, skipped inNODE_ENV === 'test'unless tests stub). - Persists/syncs
Userrows via Prisma on first login. - Signs JWT payloads shaped as
AuthJwtPayload(types).
| Method | Path | Body / cookies | Responses |
|---|---|---|---|
POST |
/auth/verify-token |
{ firebaseToken } (Zod) |
JSON access token + Set-Cookie refresh contract (see controller) |
POST |
/auth/refresh-token |
Refresh cookie | Rotates JWT access credential |
Consult authController.ts for TTLs, cookie names (HttpOnly, Secure flags in prod assumptions), error mapping.
-
Add schemas to
auth.schema.tsif widening accepted client payloads (never blindly trust arbitrary fields). -
Register new public-only endpoints on
authRouterensuring they remain aboverouter.use(requireAuth). -
If adjusting JWT signing, synchronize:
middleware/authentication.tsverification branchestypes/expresspayload typing- Client expectations (coordinate with frontend independently)
Prefer moving secret handling exclusively through ACCESS_TOKEN_SECRET (config).
Beyond login, requireAuth asserts membership; admin-only paths add requireAdmin.
Refresh tokens should remain tamper-evident and scoped (controller specifics).
| File |
|---|
test/auth/auth.schema.test.ts |
test/middleware/authentication.test.ts (JWT layering) |