mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
exception based determineAccessTokenInHeader
This commit is contained in:
@@ -33,18 +33,12 @@ class ResourceServerMiddleware
|
||||
*/
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
|
||||
{
|
||||
if ($request->hasHeader('authorization') === false) {
|
||||
$exception = OAuthServerException::accessDenied('Missing authorization header');
|
||||
|
||||
return $exception->generateHttpResponse($response);
|
||||
}
|
||||
|
||||
$request = $this->server->getResponseType()->determineAccessTokenInHeader($request);
|
||||
|
||||
if ($request->getAttribute('oauth_access_token') === null) {
|
||||
$exception = OAuthServerException::accessDenied($request->getAttribute('oauth_access_token_error'));
|
||||
|
||||
try {
|
||||
$request = $this->server->getResponseType()->determineAccessTokenInHeader($request);
|
||||
} catch (OAuthServerException $exception) {
|
||||
return $exception->generateHttpResponse($response);
|
||||
} catch (\Exception $exception) {
|
||||
return $response->withStatus(500)->write($exception->getMessage());
|
||||
}
|
||||
|
||||
// Pass the request and response on to the next responder in the chain
|
||||
|
Reference in New Issue
Block a user