Skip to content

Commit

Permalink
Merge pull request #1082 from arietimmerman/feature/invalid_grant_whe…
Browse files Browse the repository at this point in the history
…n_code_revoked

Return invalid_grant error when the authorization code is revoked
  • Loading branch information
Sephster authored Jan 31, 2020
2 parents bd05611 + 4925089 commit 0bf21a7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for PHP 7.4 (PR #1075)

### Fixed (v9)
- If a refresh token has expired, been revoked, cannot be decrypted, or does not belong to the correct client, the server will now issue an `invalid_grant` error and a HTTP 400 response. In previous versions the server incorrectly issued an `invalid_request` and HTTP 401 response (PR #1042)
- If a refresh token has expired, been revoked, cannot be decrypted, or does not belong to the correct client, the server will now issue an `invalid_grant` error and a HTTP 400 response. In previous versions the server incorrectly issued an `invalid_request` and HTTP 401 response (PR #1042) (PR #1082)

### Changed
- If an error is encountered when running `preg_match()` to validate an RSA key, the server will now throw a RuntimeException (PR #1047)
Expand Down
2 changes: 1 addition & 1 deletion src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private function validateAuthorizationCode(
}

if ($this->authCodeRepository->isAuthCodeRevoked($authCodePayload->auth_code_id) === true) {
throw OAuthServerException::invalidRequest('code', 'Authorization code has been revoked');
throw OAuthServerException::invalidGrant('Authorization code has been revoked');
}

if ($authCodePayload->client_id !== $client->getIdentifier()) {
Expand Down
1 change: 1 addition & 0 deletions tests/Grant/AuthCodeGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ public function testRespondToAccessTokenRequestRevokedCode()
$grant->respondToAccessTokenRequest($request, new StubResponseType(), new DateInterval('PT10M'));
} catch (OAuthServerException $e) {
$this->assertEquals($e->getHint(), 'Authorization code has been revoked');
$this->assertEquals($e->getErrorType(), 'invalid_grant');
}
}

Expand Down

0 comments on commit 0bf21a7

Please sign in to comment.