turtle-wow-source-kinda/Dumps/Source Code/8 - Development_website/develop/app/Http/Middleware/ApiKeyAuthentication.php
Brian Oost a1d5bb70b2 Init
2024-08-06 18:06:40 +02:00

26 lines
628 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ApiKeyAuthentication
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$apiKey = $request->header('X-API-key');
if ($apiKey !== config('customs.external.api_key')) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return $next($request);
}
}