Audit-Log: stiller Token-Refresh entrauscht (eigene Action TOKEN_REFRESH)
POST /auth/refresh wurde als CREATE / "Anmeldung erstellt" / CRITICAL / anonymous geloggt und sah damit wie eine anonyme Login-Flut aus. Es ist aber der regulaere Silent-Refresh des Frontend-Interceptors (Access-Token lebt nur im Speicher -> nach Reload/401 einmaliger Cookie-Refresh). - Neuer AuditAction-Wert TOKEN_REFRESH (Migration 20260818120000, idempotentes MODIFY COLUMN) - determineAction() mappt /auth/refresh -> TOKEN_REFRESH, Label "Sitzung verlaengert (Token erneuert)", Sensitivitaet explizit LOW (statt Default Authentication -> CRITICAL) - LOGIN/LOGOUT/LOGIN_FAILED bleiben unveraendert CRITICAL - Frontend: Filter-Option + dezente Badge-Farbe + Typ-Union - anonymous bewusst beibehalten (Endpoint ohne authenticate-Middleware) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,10 @@ function determineAction(method: string, path: string, success: boolean): AuditA
|
||||
if (path.includes('/auth/logout')) {
|
||||
return 'LOGOUT';
|
||||
}
|
||||
// Stiller Token-Refresh (Cookie) – kein interaktiver Login, eigene Action
|
||||
if (path.includes('/auth/refresh')) {
|
||||
return 'TOKEN_REFRESH';
|
||||
}
|
||||
|
||||
// Standard CRUD-Aktionen
|
||||
switch (method.toUpperCase()) {
|
||||
@@ -157,6 +161,7 @@ const ACTION_LABELS: Record<string, string> = {
|
||||
LOGIN: 'angemeldet',
|
||||
LOGOUT: 'abgemeldet',
|
||||
LOGIN_FAILED: 'Anmeldung fehlgeschlagen',
|
||||
TOKEN_REFRESH: 'Sitzung verlängert',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -198,6 +203,7 @@ function generateHumanLabel(
|
||||
: `Anmeldung fehlgeschlagen für ${email}`;
|
||||
}
|
||||
if (path.includes('/auth/logout')) return 'Benutzer hat sich abgemeldet';
|
||||
if (path.includes('/auth/refresh')) return 'Sitzung verlängert (Token erneuert)';
|
||||
|
||||
// Kunden-Operationen
|
||||
if (resourceType === 'Customer') {
|
||||
@@ -436,6 +442,9 @@ export function auditMiddleware(req: AuthRequest, res: Response, next: NextFunct
|
||||
customerId: req.user?.customerId,
|
||||
isCustomerPortal: req.user?.isCustomerPortal,
|
||||
action,
|
||||
// Stiller Token-Refresh ist Routine → LOW statt CRITICAL (sonst Log-Flut).
|
||||
// Andere Auth-Events behalten ihre Default-Sensitivität (Authentication → CRITICAL).
|
||||
sensitivity: action === 'TOKEN_REFRESH' ? 'LOW' : undefined,
|
||||
resourceType: mapping.type,
|
||||
resourceId,
|
||||
resourceLabel,
|
||||
|
||||
Reference in New Issue
Block a user