Pass errors back up the chain

This commit is contained in:
Alex Bilbie 2016-01-17 14:56:42 +00:00
parent 419cb6d149
commit 8566a128c8

View File

@ -85,12 +85,12 @@ class BearerTokenResponse extends AbstractResponseType
// Attempt to parse and validate the JWT
$token = (new Parser())->parse($jwt);
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
if ($this->accessTokenRepository->isAccessTokenRevoked($token->getClaim('jwt'))) {
return $request;
if ($this->accessTokenRepository->isAccessTokenRevoked($token->getClaim('jti'))) {
return $request->withAttribute('oauth_access_token_error', 'Access token has been revoked');
}
// Return the request with additional attributes
@ -100,7 +100,7 @@ class BearerTokenResponse extends AbstractResponseType
->withAttribute('oauth_scopes', $token->getClaim('scopes'));
} catch (\InvalidArgumentException $e) {
// JWT couldn't be parsed so return the request as is
return $request;
return $request->withAttribute('oauth_access_token_error', $e->getMessage());
}
}
}