Skip to content

Commit f2cd364

Browse files
authored
Merge pull request #970 from Sephster/interface-revert
Revert Interface Change
2 parents a61c6a3 + 7839a61 commit f2cd364

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [7.3.1] - released 2018-11-15
10+
11+
### Fixed
12+
- Fix issue with previous release where interface had changed for the AuthorizationServer. Reverted to the previous interface while maintaining functionality changes (PR #970)
13+
914
## [7.3.0] - released 2018-11-13
1015

1116
### Changed
@@ -422,7 +427,8 @@ Version 5 is a complete code rewrite.
422427

423428
- First major release
424429

425-
[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/7.3.0...HEAD
430+
[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/7.3.1...HEAD
431+
[7.3.1]: https://github.com/thephpleague/oauth2-server/compare/7.3.0...7.3.1
426432
[7.3.0]: https://github.com/thephpleague/oauth2-server/compare/7.2.0...7.3.0
427433
[7.2.0]: https://github.com/thephpleague/oauth2-server/compare/7.1.1...7.2.0
428434
[7.1.1]: https://github.com/thephpleague/oauth2-server/compare/7.1.0...7.1.1

src/AuthorizationServer.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AuthorizationServer implements EmitterAwareInterface
5252
/**
5353
* @var ResponseTypeInterface
5454
*/
55-
protected $responseTypePrototype;
55+
protected $responseType;
5656

5757
/**
5858
* @var ClientRepositoryInterface
@@ -87,15 +87,15 @@ class AuthorizationServer implements EmitterAwareInterface
8787
* @param ScopeRepositoryInterface $scopeRepository
8888
* @param CryptKey|string $privateKey
8989
* @param string|Key $encryptionKey
90-
* @param null|ResponseTypeInterface $responseTypePrototype
90+
* @param null|ResponseTypeInterface $responseType
9191
*/
9292
public function __construct(
9393
ClientRepositoryInterface $clientRepository,
9494
AccessTokenRepositoryInterface $accessTokenRepository,
9595
ScopeRepositoryInterface $scopeRepository,
9696
$privateKey,
9797
$encryptionKey,
98-
ResponseTypeInterface $responseTypePrototype = null
98+
ResponseTypeInterface $responseType = null
9999
) {
100100
$this->clientRepository = $clientRepository;
101101
$this->accessTokenRepository = $accessTokenRepository;
@@ -108,19 +108,19 @@ public function __construct(
108108
$this->privateKey = $privateKey;
109109
$this->encryptionKey = $encryptionKey;
110110

111-
if ($responseTypePrototype === null) {
112-
$responseTypePrototype = new BearerTokenResponse();
111+
if ($responseType === null) {
112+
$responseType = new BearerTokenResponse();
113113
} else {
114-
$responseTypePrototype = clone $responseTypePrototype;
114+
$responseType = clone $responseType;
115115
}
116116

117-
if ($responseTypePrototype instanceof AbstractResponseType) {
118-
$responseTypePrototype->setPrivateKey($this->privateKey);
117+
if ($responseType instanceof AbstractResponseType) {
118+
$responseType->setPrivateKey($this->privateKey);
119119
}
120120

121-
$responseTypePrototype->setEncryptionKey($this->encryptionKey);
121+
$responseType->setEncryptionKey($this->encryptionKey);
122122

123-
$this->responseTypePrototype = $responseTypePrototype;
123+
$this->responseType = $responseType;
124124
}
125125

126126
/**
@@ -200,7 +200,7 @@ public function respondToAccessTokenRequest(ServerRequestInterface $request, Res
200200
}
201201
$tokenResponse = $grantType->respondToAccessTokenRequest(
202202
$request,
203-
$this->newResponseType(),
203+
$this->getResponseType(),
204204
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
205205
);
206206

@@ -217,9 +217,9 @@ public function respondToAccessTokenRequest(ServerRequestInterface $request, Res
217217
*
218218
* @return ResponseTypeInterface
219219
*/
220-
protected function newResponseType()
220+
protected function getResponseType()
221221
{
222-
return clone $this->responseTypePrototype;
222+
return clone $this->responseType;
223223
}
224224

225225
/**

tests/AuthorizationServerTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testRespondToRequest()
9191
$this->assertEquals(200, $response->getStatusCode());
9292
}
9393

94-
public function testNewDefaultResponseType()
94+
public function testGetResponseType()
9595
{
9696
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
9797

@@ -104,17 +104,13 @@ public function testNewDefaultResponseType()
104104
);
105105

106106
$abstractGrantReflection = new \ReflectionClass($server);
107-
$method = $abstractGrantReflection->getMethod('newResponseType');
107+
$method = $abstractGrantReflection->getMethod('getResponseType');
108108
$method->setAccessible(true);
109109

110-
$responseTypeA = $method->invoke($server);
111-
$responseTypeB = $method->invoke($server);
112-
$this->assertInstanceOf(BearerTokenResponse::class, $responseTypeA);
113-
$this->assertInstanceOf(BearerTokenResponse::class, $responseTypeB);
114-
$this->assertNotSame($responseTypeA, $responseTypeB);
110+
$this->assertInstanceOf(BearerTokenResponse::class, $method->invoke($server));
115111
}
116112

117-
public function testNewResponseTypeFromPrototype()
113+
public function testMultipleRequestsGetDifferentResponseTypeInstances()
118114
{
119115
$privateKey = 'file://' . __DIR__ . '/Stubs/private.key';
120116
$encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key';
@@ -144,7 +140,7 @@ public function getEncryptionKey()
144140
);
145141

146142
$abstractGrantReflection = new \ReflectionClass($server);
147-
$method = $abstractGrantReflection->getMethod('newResponseType');
143+
$method = $abstractGrantReflection->getMethod('getResponseType');
148144
$method->setAccessible(true);
149145

150146
$responseTypeA = $method->invoke($server);

0 commit comments

Comments
 (0)