feat(auth): Admin-Zugang über Authentik-Gruppe steuern

Statt manuell gesetzter DB-Rolle erhalten Mitglieder der Authentik-Gruppe
AUTHENTIK_ADMIN_GROUP (Default floriannetz-admins) beim SSO-Login automatisch
platform_admin; Nicht-Mitglieder werden abgewiesen. Erstes Seeding entfällt.

- auth.config.ts: Scope 'openid email profile groups' anfordern
- lib/auth/authentik.ts: reine Helfer extractGroups/isAdminGroupMember (+ 7 Unit-Tests)
- auth.ts: signIn wertet groups-Claim aus, upsert (idempotent) als platform_admin
  mit stabiler users.id für Audit/FKs
- env.ts/.env.example: AUTHENTIK_ADMIN_GROUP
- docs/reference/authentik-setup.md: Provider-/Gruppen-/Scope-Setup

Verifiziert offline: tsc OK; lint sauber; vitest 240 passed / 7 skipped.
Wehr-Konten bleiben lokale Accounts (kein Authentik).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-10 09:39:13 +02:00
parent a8d07ba2ab
commit f2578cedab
7 changed files with 169 additions and 7 deletions

View File

@@ -17,6 +17,10 @@ AUTH_TRUST_HOST=true
AUTHENTIK_ISSUER=http://localhost:9000/application/o/floriannetz/
AUTHENTIK_CLIENT_ID=floriannetz
AUTHENTIK_CLIENT_SECRET=bitte-setzen
# Mitglieder dieser Authentik-Gruppe erhalten beim Login automatisch
# platform_admin. Wer NICHT in der Gruppe ist, wird vom SSO-Login abgewiesen.
# Setup siehe docs/reference/authentik-setup.md.
AUTHENTIK_ADMIN_GROUP=floriannetz-admins
# Geo (interne Dienste; Defaults zeigen auf Docker-Compose-Hostnamen)
OSRM_URL=http://osrm:5000