koel/app/Http/Middleware/ObjectStorageAuthenticate.php

31 lines
630 B
PHP
Raw Normal View History

2016-06-13 09:04:42 +00:00
<?php
namespace App\Http\Middleware;
use Closure;
2016-08-03 10:42:11 +00:00
use Illuminate\Http\Request;
2016-06-13 09:04:42 +00:00
/**
* Authenticate requests from Object Storage services (like S3).
* Such requests must have an apKey data, which matches with our app key.
*/
class ObjectStorageAuthenticate
{
/**
* Handle an incoming request.
*
2017-06-04 01:30:45 +00:00
* @param Request $request
2017-06-04 01:31:59 +00:00
* @param Closure $next
2016-06-13 09:11:41 +00:00
*
2016-06-13 09:04:42 +00:00
* @return mixed
*/
2016-08-03 10:42:11 +00:00
public function handle(Request $request, Closure $next)
2016-06-13 09:04:42 +00:00
{
if ($request->appKey !== config('app.key')) {
return response('Unauthorized.', 401);
}
return $next($request);
}
}