PDF-Generator für Eventschluss; CSRF-Protection

This commit is contained in:
2026-04-06 15:03:15 +02:00
parent 9cac0294cd
commit b48c689d31
11 changed files with 654 additions and 5 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery as Middleware;
use Illuminate\Http\Request;
class ForceCsrfOnLocalhost extends Middleware
{
/**
* Determine if the request has a valid origin based on the Sec-Fetch-Site header.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function hasValidOrigin($request)
{
// If it's localhost, we want to skip origin verification and fall back to token verification
if ($this->isLocalhost($request)) {
return false;
}
return parent::hasValidOrigin($request);
}
/**
* Determine if the request is from localhost.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function isLocalhost($request)
{
$host = $request->getHost();
return in_array($host, ['localhost', '127.0.0.1', '::1']) || str_ends_with($host, '.localhost');
}
}