deckhearth/lib
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
..
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): remove synthetic-admin bypass (Brief 2 of fix-auth-bypass) 2026-05-23 10:47:27 -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