deckhearth/lib
Randall Stillwell 4a10dcedd3 fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass)
- New `lib/auth-secret.js` is the single source of truth for `JWT_SECRET`
  and the canonical `JWT_TOKEN_TTL = '24h'`. Module throws at import time
  if `process.env.JWT_SECRET` is unset — no silent fallback to the literal
  `'your-secret-key-change-in-production'`.

- 7 callers refactored to import from the helper:
    lib/permission-middleware.js
    pages/api/auth-utils.js   (also drops unused `'7d'` → JWT_TOKEN_TTL)
    pages/api/auth/login.js   (also routes via auth-utils.generateToken)
    pages/api/auth/register.js (same)
    pages/api/auth/verify.js  (Brief 2 still owns the no-token admin branch)
    pages/api/favorites.js
    pages/api/users/search.js

- `process.env.JWT_SECRET` now appears exactly once in the JS source
  (lib/auth-secret.js). `your-secret-key-change-in-production` is gone.

- TTL drift reconciled: auth-utils used `'7d'`, login/register used
  inline `'24h'`. Both now route through imported `JWT_TOKEN_TTL` (24h).

Pre-deploy reminder: Vercel must have `JWT_SECRET` set before merge or
serverless functions refuse to boot. Existing tokens (signed against the
fallback literal) will be invalidated — users will need to log in again.

Resolves AGENTS.md gotcha #3. Brief 2/3/4/5 still pending in convoy.

Convoy: fix-auth-bypass / Brief 1
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 10:40:50 -05:00
..
flags bootstrap: agent pipeline v0.5.0 + ship-readiness review 2026-05-23 02:31:26 -05:00
admin-auth.js Integrated real database authentication with JWT tokens 2025-07-24 16:36:10 -05:00
ai-ocr.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
auth-context.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
auth-secret.js fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 10:40:50 -05:00
database.js Major redesign: Enhanced card display with particle effects, improved filters, and search functionality 2025-07-23 21:26:54 -05:00
mana-symbols.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
permission-middleware.js fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 10:40:50 -05:00
slug-utils.js 🔗 Implement Collection Slug URLs 2025-07-26 22:06:52 -05:00
theme-context.js Major redesign: Enhanced card display with particle effects, improved filters, and search functionality 2025-07-23 21:26:54 -05:00
use-auth.js 🔐 Fix Authentication Issues in Collection Pages 2025-07-26 22:23:31 -05:00