koel/app/Http/Middleware/ObjectStorageAuthenticate.php

24 lines
551 B
PHP
Raw Normal View History

2016-06-13 17:04:42 +08:00
<?php
namespace App\Http\Middleware;
use Closure;
2016-08-03 18:42:11 +08:00
use Illuminate\Http\Request;
2020-12-22 21:11:22 +01:00
use Symfony\Component\HttpFoundation\Response;
2016-06-13 17:04:42 +08:00
/**
* Authenticate requests from Object Storage services (like S3).
2020-09-14 00:04:07 +02:00
* Such requests must have an `appKey` query parameter, which matches our app key.
2016-06-13 17:04:42 +08:00
*/
class ObjectStorageAuthenticate
{
2020-12-22 21:11:22 +01:00
public function handle(Request $request, Closure $next): Response
2016-06-13 17:04:42 +08:00
{
if ($request->appKey !== config('app.key')) {
return response('Unauthorized.', 401);
}
return $next($request);
}
}