Fix uncaught exception produced by unsigned token

This commit is contained in:
Martin Dzibela 2018-05-22 14:13:20 +02:00
parent 2e47fa7fca
commit 9941a96feb

View File

@ -65,9 +65,13 @@ class BearerTokenValidator implements AuthorizationValidatorInterface
try { try {
// Attempt to parse and validate the JWT // Attempt to parse and validate the JWT
$token = (new Parser())->parse($jwt); $token = (new Parser())->parse($jwt);
try {
if ($token->verify(new Sha256(), $this->publicKey->getKeyPath()) === false) { if ($token->verify(new Sha256(), $this->publicKey->getKeyPath()) === false) {
throw OAuthServerException::accessDenied('Access token could not be verified'); throw OAuthServerException::accessDenied('Access token could not be verified');
} }
} catch (\BadMethodCallException $exception) {
throw OAuthServerException::accessDenied('Access token is not signed');
}
// Ensure access token hasn't expired // Ensure access token hasn't expired
$data = new ValidationData(); $data = new ValidationData();