fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.
This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).
Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
397
website/app/admin/rbac/wizard/page.tsx
Normal file
397
website/app/admin/rbac/wizard/page.tsx
Normal file
@@ -0,0 +1,397 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import AdminLayout from '@/components/admin/AdminLayout'
|
||||
import {
|
||||
WizardStepper,
|
||||
WizardNavigation,
|
||||
EducationCard,
|
||||
ArchitectureContext,
|
||||
TestRunner,
|
||||
TestSummary,
|
||||
type WizardStep,
|
||||
type TestCategoryResult,
|
||||
type FullTestResults,
|
||||
type EducationContent,
|
||||
type ArchitectureContextType,
|
||||
} from '@/components/wizard'
|
||||
|
||||
// ==============================================
|
||||
// Constants
|
||||
// ==============================================
|
||||
|
||||
const BACKEND_URL = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:8000'
|
||||
|
||||
const STEPS: WizardStep[] = [
|
||||
{ id: 'welcome', name: 'Willkommen', icon: '👋', status: 'pending' },
|
||||
{ id: 'authentication', name: 'Authentifizierung', icon: '🔐', status: 'pending', category: 'authentication' },
|
||||
{ id: 'roles', name: 'Rollen', icon: '👥', status: 'pending', category: 'roles' },
|
||||
{ id: 'permissions', name: 'Berechtigungen', icon: '🔑', status: 'pending', category: 'permissions' },
|
||||
{ id: 'users', name: 'Benutzer', icon: '👤', status: 'pending', category: 'users' },
|
||||
{ id: 'summary', name: 'Zusammenfassung', icon: '📊', status: 'pending' },
|
||||
]
|
||||
|
||||
const EDUCATION_CONTENT: Record<string, EducationContent> = {
|
||||
'welcome': {
|
||||
title: 'Willkommen zum RBAC Wizard',
|
||||
content: [
|
||||
'RBAC (Role-Based Access Control) ist das Herzstück der Zugriffskontrolle.',
|
||||
'',
|
||||
'Das System basiert auf drei Konzepten:',
|
||||
'• Benutzer: Personen die das System nutzen',
|
||||
'• Rollen: Gruppen von Berechtigungen (z.B. Admin, Lehrer)',
|
||||
'• Berechtigungen: Einzelne Aktionen (z.B. users:read)',
|
||||
'',
|
||||
'Standard-Rollen in BreakPilot:',
|
||||
'• user: Basis-Benutzer mit Leserechten',
|
||||
'• admin: Verwaltungsrechte',
|
||||
'• data_protection_officer: DSGVO-Freigaben',
|
||||
'',
|
||||
'JWT-Tokens enthalten Rollen und werden bei jedem Request geprueft.',
|
||||
],
|
||||
},
|
||||
'authentication': {
|
||||
title: 'Authentifizierung - Login & JWT',
|
||||
content: [
|
||||
'Die Authentifizierung prueft die Identitaet des Benutzers.',
|
||||
'',
|
||||
'Login-Flow:',
|
||||
'1. Benutzer sendet Email + Passwort',
|
||||
'2. Backend prueft Credentials gegen DB',
|
||||
'3. Bei Erfolg: JWT-Token wird generiert',
|
||||
'4. Token enthaelt: User-ID, Rollen, Ablaufzeit',
|
||||
'',
|
||||
'JWT-Validierung:',
|
||||
'• Signatur wird bei jedem Request geprueft',
|
||||
'• Abgelaufene Tokens werden abgelehnt',
|
||||
'• Manipulierte Tokens werden erkannt',
|
||||
'',
|
||||
'Sicherheit: bcrypt fuer Passwort-Hashing',
|
||||
],
|
||||
},
|
||||
'roles': {
|
||||
title: 'Rollen - Berechtigungsgruppen',
|
||||
content: [
|
||||
'Rollen buendeln Berechtigungen fuer einfache Verwaltung.',
|
||||
'',
|
||||
'Standard-Rollen:',
|
||||
'• user: Basis-Zugriff, eigene Daten lesen',
|
||||
'• admin: Alle Verwaltungsfunktionen',
|
||||
'• data_protection_officer: DSGVO-Freigaben',
|
||||
'',
|
||||
'Rollen-Hierarchie:',
|
||||
'admin erbt alle user-Rechte',
|
||||
'DSB hat spezielle DSGVO-Rechte',
|
||||
'',
|
||||
'Best Practices:',
|
||||
'• Minimale Rechte vergeben (Least Privilege)',
|
||||
'• Rollen regelmaessig ueberpruefen',
|
||||
'• Keine direkten Berechtigungen an Benutzer',
|
||||
],
|
||||
},
|
||||
'permissions': {
|
||||
title: 'Berechtigungen - Granulare Kontrolle',
|
||||
content: [
|
||||
'Berechtigungen definieren einzelne erlaubte Aktionen.',
|
||||
'',
|
||||
'Format: resource:action',
|
||||
'• users:read - Benutzer lesen',
|
||||
'• users:write - Benutzer erstellen/aendern',
|
||||
'• consent:approve - Einwilligungen freigeben',
|
||||
'• dsr:process - Datenschutzanfragen bearbeiten',
|
||||
'',
|
||||
'Zuordnung:',
|
||||
'Berechtigungen → Rollen → Benutzer',
|
||||
'',
|
||||
'Pruefung im Code:',
|
||||
'if user.has_permission("consent:approve"):',
|
||||
' # Aktion erlauben',
|
||||
],
|
||||
},
|
||||
'users': {
|
||||
title: 'Benutzer - Identitaeten verwalten',
|
||||
content: [
|
||||
'Benutzer sind die Personen die das System nutzen.',
|
||||
'',
|
||||
'Benutzer-Attribute:',
|
||||
'• ID: Eindeutige Kennung (UUID)',
|
||||
'• Email: Login-Kennung',
|
||||
'• Name: Anzeigename',
|
||||
'• Rollen: Zugewiesene Rollen',
|
||||
'• Status: aktiv/inaktiv',
|
||||
'',
|
||||
'Verwaltungs-Aktionen:',
|
||||
'• Benutzer erstellen',
|
||||
'• Rollen zuweisen/entziehen',
|
||||
'• Benutzer deaktivieren',
|
||||
'• Passwort zuruecksetzen',
|
||||
'',
|
||||
'DSGVO: Benutzer koennen Datenlöschung beantragen',
|
||||
],
|
||||
},
|
||||
'summary': {
|
||||
title: 'Test-Zusammenfassung',
|
||||
content: [
|
||||
'Hier sehen Sie eine Uebersicht aller durchgefuehrten Tests:',
|
||||
'• Authentifizierungs-Endpoints',
|
||||
'• Rollen-Verwaltung',
|
||||
'• Berechtigungs-System',
|
||||
'• Benutzer-API',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
const ARCHITECTURE_CONTEXTS: Record<string, ArchitectureContextType> = {
|
||||
'authentication': {
|
||||
layer: 'api',
|
||||
services: ['backend', 'consent-service'],
|
||||
dependencies: ['PostgreSQL', 'JWT', 'bcrypt'],
|
||||
dataFlow: ['Browser', 'FastAPI', 'Auth Service', 'PostgreSQL'],
|
||||
},
|
||||
'roles': {
|
||||
layer: 'service',
|
||||
services: ['backend'],
|
||||
dependencies: ['PostgreSQL', 'Roles Table', 'RBAC Middleware'],
|
||||
dataFlow: ['API Request', 'RBAC Check', 'Roles Table', 'Response'],
|
||||
},
|
||||
'permissions': {
|
||||
layer: 'service',
|
||||
services: ['backend'],
|
||||
dependencies: ['PostgreSQL', 'Permissions Table', 'Role-Permission Mapping'],
|
||||
dataFlow: ['User Action', 'Permission Check', 'DB Lookup', 'Allow/Deny'],
|
||||
},
|
||||
'users': {
|
||||
layer: 'database',
|
||||
services: ['backend', 'consent-service'],
|
||||
dependencies: ['PostgreSQL', 'Users Table', 'Valkey Session'],
|
||||
dataFlow: ['Admin UI', 'FastAPI', 'User Service', 'PostgreSQL'],
|
||||
},
|
||||
}
|
||||
|
||||
// ==============================================
|
||||
// Main Component
|
||||
// ==============================================
|
||||
|
||||
export default function RBACWizardPage() {
|
||||
const [currentStep, setCurrentStep] = useState(0)
|
||||
const [steps, setSteps] = useState<WizardStep[]>(STEPS)
|
||||
const [categoryResults, setCategoryResults] = useState<Record<string, TestCategoryResult>>({})
|
||||
const [fullResults, setFullResults] = useState<FullTestResults | null>(null)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
const currentStepData = steps[currentStep]
|
||||
const isTestStep = currentStepData?.category !== undefined
|
||||
const isWelcome = currentStepData?.id === 'welcome'
|
||||
const isSummary = currentStepData?.id === 'summary'
|
||||
|
||||
const runCategoryTest = async (category: string) => {
|
||||
setIsLoading(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
const response = await fetch(`${BACKEND_URL}/api/admin/rbac-tests/${category}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
||||
}
|
||||
|
||||
const result: TestCategoryResult = await response.json()
|
||||
setCategoryResults((prev) => ({ ...prev, [category]: result }))
|
||||
|
||||
setSteps((prev) =>
|
||||
prev.map((step) =>
|
||||
step.category === category
|
||||
? { ...step, status: result.failed === 0 ? 'completed' : 'failed' }
|
||||
: step
|
||||
)
|
||||
)
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const runAllTests = async () => {
|
||||
setIsLoading(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
const response = await fetch(`${BACKEND_URL}/api/admin/rbac-tests/run-all`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
||||
}
|
||||
|
||||
const results: FullTestResults = await response.json()
|
||||
setFullResults(results)
|
||||
|
||||
setSteps((prev) =>
|
||||
prev.map((step) => {
|
||||
if (step.category) {
|
||||
const catResult = results.categories.find((c) => c.category === step.category)
|
||||
if (catResult) {
|
||||
return { ...step, status: catResult.failed === 0 ? 'completed' : 'failed' }
|
||||
}
|
||||
}
|
||||
return step
|
||||
})
|
||||
)
|
||||
|
||||
const newCategoryResults: Record<string, TestCategoryResult> = {}
|
||||
results.categories.forEach((cat) => {
|
||||
newCategoryResults[cat.category] = cat
|
||||
})
|
||||
setCategoryResults(newCategoryResults)
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Unbekannter Fehler')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const goToNext = () => {
|
||||
if (currentStep < steps.length - 1) {
|
||||
setSteps((prev) =>
|
||||
prev.map((step, idx) =>
|
||||
idx === currentStep && step.status === 'pending'
|
||||
? { ...step, status: 'completed' }
|
||||
: step
|
||||
)
|
||||
)
|
||||
setCurrentStep((prev) => prev + 1)
|
||||
}
|
||||
}
|
||||
|
||||
const goToPrev = () => {
|
||||
if (currentStep > 0) {
|
||||
setCurrentStep((prev) => prev - 1)
|
||||
}
|
||||
}
|
||||
|
||||
const handleStepClick = (index: number) => {
|
||||
if (index <= currentStep || steps[index - 1]?.status !== 'pending') {
|
||||
setCurrentStep(index)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<AdminLayout
|
||||
title="RBAC Wizard"
|
||||
description="Interaktives Lernen und Testen der Zugriffskontrolle"
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="bg-white rounded-lg shadow p-4 mb-6 flex items-center justify-between">
|
||||
<div className="flex items-center">
|
||||
<span className="text-3xl mr-3">🔐</span>
|
||||
<div>
|
||||
<h2 className="text-lg font-bold text-gray-800">RBAC Wizard</h2>
|
||||
<p className="text-sm text-gray-600">Rollen, Berechtigungen & Authentifizierung</p>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/admin/rbac" className="text-blue-600 hover:text-blue-800 text-sm">
|
||||
← Zurueck zu RBAC
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{/* Stepper */}
|
||||
<div className="bg-white rounded-lg shadow p-6 mb-6">
|
||||
<WizardStepper steps={steps} currentStep={currentStep} onStepClick={handleStepClick} />
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="bg-white rounded-lg shadow p-6">
|
||||
<div className="flex items-center mb-6">
|
||||
<span className="text-3xl mr-3">{currentStepData?.icon}</span>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-gray-800">
|
||||
Schritt {currentStep + 1}: {currentStepData?.name}
|
||||
</h2>
|
||||
<p className="text-gray-500 text-sm">
|
||||
{currentStep + 1} von {steps.length}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EducationCard content={EDUCATION_CONTENT[currentStepData?.id || '']} />
|
||||
|
||||
{isTestStep && currentStepData?.category && ARCHITECTURE_CONTEXTS[currentStepData.category] && (
|
||||
<ArchitectureContext
|
||||
context={ARCHITECTURE_CONTEXTS[currentStepData.category]}
|
||||
currentStep={currentStepData.name}
|
||||
/>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="bg-red-50 border border-red-200 text-red-700 rounded-lg p-4 mb-6">
|
||||
<strong>Fehler:</strong> {error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isWelcome && (
|
||||
<div className="text-center py-8">
|
||||
<button
|
||||
onClick={goToNext}
|
||||
className="bg-blue-600 text-white px-8 py-3 rounded-lg font-medium hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
Wizard starten
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isTestStep && currentStepData?.category && (
|
||||
<TestRunner
|
||||
category={currentStepData.category}
|
||||
categoryResult={categoryResults[currentStepData.category]}
|
||||
isLoading={isLoading}
|
||||
onRunTests={() => runCategoryTest(currentStepData.category!)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isSummary && (
|
||||
<div>
|
||||
{!fullResults ? (
|
||||
<div className="text-center py-8">
|
||||
<p className="text-gray-600 mb-4">
|
||||
Fuehren Sie alle Tests aus um eine Zusammenfassung zu sehen.
|
||||
</p>
|
||||
<button
|
||||
onClick={runAllTests}
|
||||
disabled={isLoading}
|
||||
className={`px-6 py-3 rounded-lg font-medium transition-colors ${
|
||||
isLoading
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-blue-600 text-white hover:bg-blue-700'
|
||||
}`}
|
||||
>
|
||||
{isLoading ? 'Alle Tests laufen...' : 'Alle Tests ausfuehren'}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<TestSummary results={fullResults} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<WizardNavigation
|
||||
currentStep={currentStep}
|
||||
totalSteps={steps.length}
|
||||
onPrev={goToPrev}
|
||||
onNext={goToNext}
|
||||
showNext={!isSummary}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="text-center text-gray-500 text-sm mt-6">
|
||||
Diese Tests pruefen die Zugriffskontroll-Infrastruktur.
|
||||
Bei Fragen wenden Sie sich an das Security-Team.
|
||||
</div>
|
||||
</AdminLayout>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user