mirror of
https://gitlab.com/izyim/prototypes/lumen-microservices/microservice-products-api.git
synced 2026-08-19 04:14:09 +00:00
28 lines
564 B
PHP
28 lines
564 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Response;
|
|
|
|
class AuthenticateAccess
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$allowedSecrets = explode(',', env('ALLOWED_SECRETS'));
|
|
|
|
if (in_array($request->header('Authorization'), $allowedSecrets)) {
|
|
return $next($request);
|
|
}
|
|
|
|
abort(Response::HTTP_UNAUTHORIZED);
|
|
}
|
|
}
|