security: add HTTP security headers, rate limiting on sensitive routes, and file upload extension validation

This commit is contained in:
2026-11-01 16:46:03 +01:00
parent 2d44647f94
commit ef19221b62
7 changed files with 50 additions and 9 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ class CartController extends Controller
$validated = $request->validate([
'model_name' => 'nullable|string|max:255',
'model_url' => 'nullable|url|max:1000',
'model_file' => 'nullable|file|max:51200', // 50MB
'model_file' => 'nullable|file|extensions:stl,3mf,obj,step,stp,zip|max:51200', // 50MB
'size' => 'required|in:klein,medium,groot',
'material' => 'required|string',
'color' => 'required|string',
+1 -1
View File
@@ -106,7 +106,7 @@ class ShopController extends Controller
'preferred_material' => 'nullable|string|max:50',
'preferred_color' => 'nullable|string|max:50',
'dimensions' => 'nullable|string|max:100',
'model_file' => 'nullable|file|max:51200', // max 50MB (stl, step, obj, zip)
'model_file' => 'nullable|file|extensions:stl,3mf,obj,step,stp,zip|max:51200', // max 50MB (stl, step, obj, zip)
]);
$filePath = null;
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class AddSecurityHeaders
{
/**
* Handle an incoming request and append modern security headers.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->headers->set('Referrer-Policy', 'strict-origin-when-cross-origin');
$response->headers->set('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');
return $response;
}
}