csrf handling mit der korrekten middleware verbunden

This commit is contained in:
Codex Agent
2025-12-23 09:54:26 +01:00
parent 826e2a93ce
commit ed5c1918fc
3 changed files with 10 additions and 3 deletions

View File

@@ -56,7 +56,9 @@ class Handler extends ExceptionHandler
public function render($request, Throwable $e)
{
if ($e instanceof TokenMismatchException) {
$this->logCsrfMismatch($request);
$this->logCsrfMismatch($request, 'token_mismatch');
} elseif ($e instanceof HttpExceptionInterface && $e->getStatusCode() === 419) {
$this->logCsrfMismatch($request, 'http_419');
}
if ($request->expectsJson()) {
@@ -251,13 +253,14 @@ class Handler extends ExceptionHandler
return $throwable instanceof $className;
}
private function logCsrfMismatch($request): void
private function logCsrfMismatch($request, string $reason): void
{
if (! app()->environment('development')) {
return;
}
Log::warning('[CSRF] Token mismatch', [
'reason' => $reason,
'method' => $request->method(),
'path' => $request->path(),
'full_url' => $request->fullUrl(),