From 443d7c485a605ebb395ece49e5963666965ec36f Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 15 Nov 2018 22:22:08 +0000 Subject: [PATCH 1/2] Revert interface change so class can be extende --- src/AuthorizationServer.php | 26 +++++++++++++------------- tests/AuthorizationServerTest.php | 14 +++++--------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 35597de1c..e96ce04f9 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -52,7 +52,7 @@ class AuthorizationServer implements EmitterAwareInterface /** * @var ResponseTypeInterface */ - protected $responseTypePrototype; + protected $responseType; /** * @var ClientRepositoryInterface @@ -87,7 +87,7 @@ class AuthorizationServer implements EmitterAwareInterface * @param ScopeRepositoryInterface $scopeRepository * @param CryptKey|string $privateKey * @param string|Key $encryptionKey - * @param null|ResponseTypeInterface $responseTypePrototype + * @param null|ResponseTypeInterface $responseType */ public function __construct( ClientRepositoryInterface $clientRepository, @@ -95,7 +95,7 @@ public function __construct( ScopeRepositoryInterface $scopeRepository, $privateKey, $encryptionKey, - ResponseTypeInterface $responseTypePrototype = null + ResponseTypeInterface $responseType = null ) { $this->clientRepository = $clientRepository; $this->accessTokenRepository = $accessTokenRepository; @@ -108,19 +108,19 @@ public function __construct( $this->privateKey = $privateKey; $this->encryptionKey = $encryptionKey; - if ($responseTypePrototype === null) { - $responseTypePrototype = new BearerTokenResponse(); + if ($responseType === null) { + $responseType = new BearerTokenResponse(); } else { - $responseTypePrototype = clone $responseTypePrototype; + $responseType = clone $responseType; } - if ($responseTypePrototype instanceof AbstractResponseType) { - $responseTypePrototype->setPrivateKey($this->privateKey); + if ($responseType instanceof AbstractResponseType) { + $responseType->setPrivateKey($this->privateKey); } - $responseTypePrototype->setEncryptionKey($this->encryptionKey); + $responseType->setEncryptionKey($this->encryptionKey); - $this->responseTypePrototype = $responseTypePrototype; + $this->responseType = $responseType; } /** @@ -200,7 +200,7 @@ public function respondToAccessTokenRequest(ServerRequestInterface $request, Res } $tokenResponse = $grantType->respondToAccessTokenRequest( $request, - $this->newResponseType(), + $this->getResponseType(), $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] ); @@ -217,9 +217,9 @@ public function respondToAccessTokenRequest(ServerRequestInterface $request, Res * * @return ResponseTypeInterface */ - protected function newResponseType() + protected function getResponseType() { - return clone $this->responseTypePrototype; + return clone $this->responseType; } /** diff --git a/tests/AuthorizationServerTest.php b/tests/AuthorizationServerTest.php index 9e485501c..73f84a61c 100644 --- a/tests/AuthorizationServerTest.php +++ b/tests/AuthorizationServerTest.php @@ -91,7 +91,7 @@ public function testRespondToRequest() $this->assertEquals(200, $response->getStatusCode()); } - public function testNewDefaultResponseType() + public function testGetResponseType() { $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); @@ -104,17 +104,13 @@ public function testNewDefaultResponseType() ); $abstractGrantReflection = new \ReflectionClass($server); - $method = $abstractGrantReflection->getMethod('newResponseType'); + $method = $abstractGrantReflection->getMethod('getResponseType'); $method->setAccessible(true); - $responseTypeA = $method->invoke($server); - $responseTypeB = $method->invoke($server); - $this->assertInstanceOf(BearerTokenResponse::class, $responseTypeA); - $this->assertInstanceOf(BearerTokenResponse::class, $responseTypeB); - $this->assertNotSame($responseTypeA, $responseTypeB); + $this->assertInstanceOf(BearerTokenResponse::class, $method->invoke($server)); } - public function testNewResponseTypeFromPrototype() + public function testMultipleRequestsGetDifferentResponseTypeInstances() { $privateKey = 'file://' . __DIR__ . '/Stubs/private.key'; $encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key'; @@ -144,7 +140,7 @@ public function getEncryptionKey() ); $abstractGrantReflection = new \ReflectionClass($server); - $method = $abstractGrantReflection->getMethod('newResponseType'); + $method = $abstractGrantReflection->getMethod('getResponseType'); $method->setAccessible(true); $responseTypeA = $method->invoke($server); From 7839a61170b2307792c2d889ca17ee7bc34b456d Mon Sep 17 00:00:00 2001 From: sephster Date: Thu, 15 Nov 2018 22:33:34 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a922b62..bceb11f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [7.3.1] - released 2018-11-15 + +### Fixed +- Fix issue with previous release where interface had changed for the AuthorizationServer. Reverted to the previous interface while maintaining functionality changes (PR #970) + ## [7.3.0] - released 2018-11-13 ### Changed @@ -422,7 +427,8 @@ Version 5 is a complete code rewrite. - First major release -[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/7.3.0...HEAD +[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/7.3.1...HEAD +[7.3.1]: https://github.com/thephpleague/oauth2-server/compare/7.3.0...7.3.1 [7.3.0]: https://github.com/thephpleague/oauth2-server/compare/7.2.0...7.3.0 [7.2.0]: https://github.com/thephpleague/oauth2-server/compare/7.1.1...7.2.0 [7.1.1]: https://github.com/thephpleague/oauth2-server/compare/7.1.0...7.1.1