csrf handling mit der korrekten middleware verbunden
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user