fix(auth): JWT-Secret härten und Session-Laufzeit verkürzen

- Gemeinsames Secret-Modul (jwt-secret.ts): bricht in Produktion hart ab,
  wenn NEXTAUTH_SECRET fehlt oder <32 Zeichen – kein öffentlicher Fallback mehr
- auth.ts und middleware.ts nutzen dieselbe Secret-Quelle (kein Divergieren)
- Schwacher Compose-Fallback entfernt: Deployment ohne Secret bricht ab (:?)
- "Angemeldet bleiben" 30 → 14 Tage; Laufzeiten zentralisiert (SESSION_MAX_AGE_*)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pepe Ziberi
2026-07-18 20:11:56 +02:00
parent 08ecf4c61a
commit 93af663dd1
6 changed files with 47 additions and 17 deletions

View File

@@ -1,9 +1,6 @@
import { NextRequest, NextResponse } from 'next/server'
import { jwtVerify } from 'jose'
const JWT_SECRET = new TextEncoder().encode(
process.env.NEXTAUTH_SECRET || 'dev-only-fallback-do-not-use-in-production'
)
import { JWT_SECRET } from './lib/jwt-secret'
// Routes that require authentication
const PROTECTED_ROUTES = ['/app', '/settings', '/admin']