deckhearth/pages/api
Randall Stillwell 5d72277355 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 09:47:11 -05:00
..
admin Major Scanner Improvements 2025-07-29 14:19:48 -05:00
auth fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 09:47:11 -05:00
cards Major Scanner Improvements 2025-07-29 14:19:48 -05:00
collections Major Scanner Improvements 2025-07-29 14:19:48 -05:00
community 🌍 Separate My Collections & Community Collections 2025-07-27 13:17:13 -05:00
config Major Scanner Improvements 2025-07-29 14:19:48 -05:00
decks Major Scanner Improvements 2025-07-29 14:19:48 -05:00
invite 🎉 COMPLETED: Full Collaborative Collections System 2025-07-25 08:34:28 -05:00
public Major Scanner Improvements 2025-07-29 14:19:48 -05:00
user 🖼️ Complete Avatar Upload System with Vercel Blob 2025-07-26 21:39:42 -05:00
users fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 09:47:11 -05:00
auth-utils.js fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 09:47:11 -05:00
collections.js 🔧 Fix SQL Template Literal Syntax Error 2025-07-27 20:00:20 -05:00
decks.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
favorites.js fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 09:47:11 -05:00
health.js Clean slate: Remove React traces and create pure Next.js setup 2025-07-23 09:32:31 -05:00
setup-database.js Fix bcryptjs imports to use dynamic imports 2025-07-23 09:40:50 -05:00
simple.js Add simple API test without dependencies 2025-07-23 09:42:30 -05:00
test-auth.js Major redesign: Enhanced card display with particle effects, improved filters, and search functionality 2025-07-23 21:26:54 -05:00
test-db.js Major redesign: Enhanced card display with particle effects, improved filters, and search functionality 2025-07-23 21:26:54 -05:00
user-cards.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00