deckhearth/pages/api
Randall Stillwell 27e924c7cd fix(auth): remove synthetic-admin bypass (Brief 2 of fix-auth-bypass)
Closes AGENTS.md gotcha #2: getUserFromRequest no longer returns a
hardcoded { userId: 1, email: 'admin@tcgvault.com', role: 'admin' }
when the Authorization header is missing or malformed.

lib/permission-middleware.js
  - getUserFromRequest now returns null for missing/malformed Bearer
    headers. No console.warn, no NODE_ENV gate — the fallback is gone,
    period.
  - Token-verify path and DB lookup unchanged.

pages/api/auth/verify.js
  - No-token branch now returns 401 instead of fetching the seed admin
    via `WHERE email = 'admin@tcgvault.com'`. Closes the admin-record-
    leak side of the same bypass.
  - JWT-verify branch unchanged.

Known follow-up (flagged but NOT addressed in this PR):
  pages/api/collections/[identifier]/cards.js POST/PUT/DELETE handlers
  dereference user.userId without a null guard. Previously masked by
  the synthetic admin (anonymous-write-as-admin on collections owned
  by user 1 was the security hole). Now degrades to NPE → 500 instead
  of a clean 401. Security is improved either way; cosmetic 500-vs-401
  fix lives in a separate one-line follow-up PR.

Convoy: fix-auth-bypass / Brief 2
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 10:47:27 -05:00
..
admin Major Scanner Improvements 2025-07-29 14:19:48 -05:00
auth fix(auth): remove synthetic-admin bypass (Brief 2 of fix-auth-bypass) 2026-05-23 10:47:27 -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 10:40:50 -05:00
auth-utils.js fix(auth): centralize JWT secret + 24h TTL (Brief 1 of fix-auth-bypass) 2026-05-23 10:40:50 -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 10:40:50 -05:00
health.js Clean slate: Remove React traces and create pure Next.js setup 2025-07-23 09:32:31 -05:00
user-cards.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00