koel/app/Http/Middleware/ObjectStorageAuthenticate.php

22 lines
524 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;
2022-07-29 06:47:10 +00:00
use Illuminate\Http\Response;
2016-06-13 09:04:42 +00:00
/**
* Authenticate requests from Object Storage services (like S3).
2020-09-13 22:04:07 +00:00
* Such requests must have an `appKey` query parameter, which matches our app key.
2016-06-13 09:04:42 +00:00
*/
class ObjectStorageAuthenticate
{
2021-06-05 10:47:56 +00:00
public function handle(Request $request, Closure $next) // @phpcs:ignore
2016-06-13 09:04:42 +00:00
{
2022-07-29 06:47:10 +00:00
abort_unless($request->get('appKey') === config('app.key'), Response::HTTP_UNAUTHORIZED);
2016-06-13 09:04:42 +00:00
return $next($request);
}
}