1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/backend/app/Http/Middleware/HttpBasicAuth.php
Tim Meier 498d7baa51 Add api for updating files (#50)
* Update vagrantfile

* Add http basic auth

* Add new api for FP to call

* refactor
2017-02-19 01:55:33 +01:00

25 lines
595 B
PHP

<?php
namespace App\Http\Middleware;
use Illuminate\Http\Response;
class HttpBasicAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, $next)
{
if($request->getUser() == config('auth.HTTP_BASIC_USERNAME') && $request->getPassword() == config('auth.HTTP_BASIC_PASSWORD')) {
return $next($request);
}
return response('Invalid credentials.', Response::HTTP_UNAUTHORIZED, ['WWW-Authenticate' => 'Basic']);
}
}