Skip to content

Commit 234aafe

Browse files
committed
Ensure refresh token returned is new after use
1 parent b8e1830 commit 234aafe

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Fixed bug where you could not omit a redirect uri even if one had not been specified during the auth request (PR #1428)
1111
- Fixed bug where "state" parameter wasn't present on `invalid_scope` error response and wasn't on fragment part of `access_denied` redirect URI on Implicit grant (PR #1298)
1212
- Fixed bug where disabling refresh token revocation via `revokeRefreshTokens(false)` unintentionally disables issuing new refresh token (PR #1449)
13-
-
13+
1414
## [9.0.0] - released 2024-05-13
1515
### Added
1616
- Device Authorization Grant added (PR #1074)

tests/Grant/RefreshTokenGrantTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,10 @@ public function testRespondToRequestFinalizeScopes(): void
594594
);
595595

596596
$serverRequest = (new ServerRequest())->withParsedBody([
597-
'client_id' => 'foo',
598-
'client_secret' => 'bar',
599-
'refresh_token' => $encryptedOldRefreshToken,
600-
'scope' => 'foo bar',
597+
'client_id' => 'foo',
598+
'client_secret' => 'bar',
599+
'refresh_token' => $encryptedOldRefreshToken,
600+
'scope' => 'foo bar',
601601
]);
602602

603603
$responseType = new StubResponseType();
@@ -630,7 +630,7 @@ public function testRevokedRefreshToken(): void
630630

631631
$refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
632632
$refreshTokenRepositoryMock->method('isRefreshTokenRevoked')
633-
->will(self::onConsecutiveCalls(false, true));
633+
->will(self::onConsecutiveCalls(false, true));
634634
$refreshTokenRepositoryMock->expects(self::once())->method('revokeRefreshToken')->with(self::equalTo($refreshTokenId));
635635

636636
$oldRefreshToken = json_encode(
@@ -728,12 +728,14 @@ public function testUnrevokedRefreshToken(): void
728728
'scope' => 'foo',
729729
]);
730730

731+
$privateKey = new CryptKey('file://' . __DIR__ . '/../Stubs/private.key');
732+
731733
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
732734
$grant->setClientRepository($clientRepositoryMock);
733735
$grant->setScopeRepository($scopeRepositoryMock);
734736
$grant->setAccessTokenRepository($accessTokenRepositoryMock);
735737
$grant->setEncryptionKey($this->cryptStub->getKey());
736-
$grant->setPrivateKey($privateKey = new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
738+
$grant->setPrivateKey($privateKey);
737739
$grant->revokeRefreshTokens(false);
738740

739741
$responseType = new BearerTokenResponse();
@@ -750,5 +752,6 @@ public function testUnrevokedRefreshToken(): void
750752
self::assertObjectHasProperty('expires_in', $json);
751753
self::assertObjectHasProperty('access_token', $json);
752754
self::assertObjectHasProperty('refresh_token', $json);
755+
self::assertNotSame($json->refresh_token, $encryptedOldRefreshToken);
753756
}
754757
}

0 commit comments

Comments
 (0)