feat: add API key authentication middleware
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

Adds `VerifyApiKey` middleware to validate `X-Api-Key` header against `app.api_secret_key` config. Returns 403 if key is missing or invalid.
This commit is contained in:
Ovidiu U
2026-04-05 20:27:57 +01:00
parent 1860cf0a49
commit 7e1a000e2a

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class VerifyApiKey
{
/**
* Handle an incoming request.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if ($request->header('X-Api-Key') !== config('app.api_secret_key')) {
abort(403);
}
return $next($request);
}
}