40 lines
766 B
PHP
40 lines
766 B
PHP
<?php namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Routing\Middleware;
|
|
use Illuminate\Contracts\Auth\Authenticator;
|
|
|
|
class BasicAuthMiddleware implements Middleware {
|
|
|
|
/**
|
|
* The authenticator implementation.
|
|
*
|
|
* @var Authenticator
|
|
*/
|
|
protected $auth;
|
|
|
|
/**
|
|
* Create a new filter instance.
|
|
*
|
|
* @param Authenticator $auth
|
|
* @return void
|
|
*/
|
|
public function __construct(Authenticator $auth)
|
|
{
|
|
$this->auth = $auth;
|
|
}
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Symfony\Component\HttpFoundation\Request $request
|
|
* @param \Closure $next
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
return $this->auth->basic() ?: $next($request);
|
|
}
|
|
|
|
}
|