mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
Pass errors back up the chain
This commit is contained in:
@ -85,12 +85,12 @@ class BearerTokenResponse extends AbstractResponseType
|
|||||||
// Attempt to parse and validate the JWT
|
// Attempt to parse and validate the JWT
|
||||||
$token = (new Parser())->parse($jwt);
|
$token = (new Parser())->parse($jwt);
|
||||||
if ($token->verify(new Sha256(), $this->pathToPublicKey) === false) {
|
if ($token->verify(new Sha256(), $this->pathToPublicKey) === false) {
|
||||||
return $request;
|
return $request->withAttribute('oauth_access_token_error', 'Access token could not be verified');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if token has been revoked
|
// Check if token has been revoked
|
||||||
if ($this->accessTokenRepository->isAccessTokenRevoked($token->getClaim('jwt'))) {
|
if ($this->accessTokenRepository->isAccessTokenRevoked($token->getClaim('jti'))) {
|
||||||
return $request;
|
return $request->withAttribute('oauth_access_token_error', 'Access token has been revoked');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the request with additional attributes
|
// Return the request with additional attributes
|
||||||
@ -100,7 +100,7 @@ class BearerTokenResponse extends AbstractResponseType
|
|||||||
->withAttribute('oauth_scopes', $token->getClaim('scopes'));
|
->withAttribute('oauth_scopes', $token->getClaim('scopes'));
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
// JWT couldn't be parsed so return the request as is
|
// JWT couldn't be parsed so return the request as is
|
||||||
return $request;
|
return $request->withAttribute('oauth_access_token_error', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user