mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 21:19:46 +05:30
Revert interface change so class can be extende
This commit is contained in:
parent
a61c6a318a
commit
443d7c485a
@ -52,7 +52,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* @var ResponseTypeInterface
|
* @var ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
protected $responseTypePrototype;
|
protected $responseType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ClientRepositoryInterface
|
* @var ClientRepositoryInterface
|
||||||
@ -87,7 +87,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
* @param ScopeRepositoryInterface $scopeRepository
|
* @param ScopeRepositoryInterface $scopeRepository
|
||||||
* @param CryptKey|string $privateKey
|
* @param CryptKey|string $privateKey
|
||||||
* @param string|Key $encryptionKey
|
* @param string|Key $encryptionKey
|
||||||
* @param null|ResponseTypeInterface $responseTypePrototype
|
* @param null|ResponseTypeInterface $responseType
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ClientRepositoryInterface $clientRepository,
|
ClientRepositoryInterface $clientRepository,
|
||||||
@ -95,7 +95,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
ScopeRepositoryInterface $scopeRepository,
|
ScopeRepositoryInterface $scopeRepository,
|
||||||
$privateKey,
|
$privateKey,
|
||||||
$encryptionKey,
|
$encryptionKey,
|
||||||
ResponseTypeInterface $responseTypePrototype = null
|
ResponseTypeInterface $responseType = null
|
||||||
) {
|
) {
|
||||||
$this->clientRepository = $clientRepository;
|
$this->clientRepository = $clientRepository;
|
||||||
$this->accessTokenRepository = $accessTokenRepository;
|
$this->accessTokenRepository = $accessTokenRepository;
|
||||||
@ -108,19 +108,19 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
$this->privateKey = $privateKey;
|
$this->privateKey = $privateKey;
|
||||||
$this->encryptionKey = $encryptionKey;
|
$this->encryptionKey = $encryptionKey;
|
||||||
|
|
||||||
if ($responseTypePrototype === null) {
|
if ($responseType === null) {
|
||||||
$responseTypePrototype = new BearerTokenResponse();
|
$responseType = new BearerTokenResponse();
|
||||||
} else {
|
} else {
|
||||||
$responseTypePrototype = clone $responseTypePrototype;
|
$responseType = clone $responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($responseTypePrototype instanceof AbstractResponseType) {
|
if ($responseType instanceof AbstractResponseType) {
|
||||||
$responseTypePrototype->setPrivateKey($this->privateKey);
|
$responseType->setPrivateKey($this->privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
$responseTypePrototype->setEncryptionKey($this->encryptionKey);
|
$responseType->setEncryptionKey($this->encryptionKey);
|
||||||
|
|
||||||
$this->responseTypePrototype = $responseTypePrototype;
|
$this->responseType = $responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +200,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
}
|
}
|
||||||
$tokenResponse = $grantType->respondToAccessTokenRequest(
|
$tokenResponse = $grantType->respondToAccessTokenRequest(
|
||||||
$request,
|
$request,
|
||||||
$this->newResponseType(),
|
$this->getResponseType(),
|
||||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -217,9 +217,9 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
*
|
*
|
||||||
* @return ResponseTypeInterface
|
* @return ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
protected function newResponseType()
|
protected function getResponseType()
|
||||||
{
|
{
|
||||||
return clone $this->responseTypePrototype;
|
return clone $this->responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,7 @@ class AuthorizationServerTest extends TestCase
|
|||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNewDefaultResponseType()
|
public function testGetResponseType()
|
||||||
{
|
{
|
||||||
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
||||||
|
|
||||||
@ -104,17 +104,13 @@ class AuthorizationServerTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$abstractGrantReflection = new \ReflectionClass($server);
|
$abstractGrantReflection = new \ReflectionClass($server);
|
||||||
$method = $abstractGrantReflection->getMethod('newResponseType');
|
$method = $abstractGrantReflection->getMethod('getResponseType');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$responseTypeA = $method->invoke($server);
|
$this->assertInstanceOf(BearerTokenResponse::class, $method->invoke($server));
|
||||||
$responseTypeB = $method->invoke($server);
|
|
||||||
$this->assertInstanceOf(BearerTokenResponse::class, $responseTypeA);
|
|
||||||
$this->assertInstanceOf(BearerTokenResponse::class, $responseTypeB);
|
|
||||||
$this->assertNotSame($responseTypeA, $responseTypeB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNewResponseTypeFromPrototype()
|
public function testMultipleRequestsGetDifferentResponseTypeInstances()
|
||||||
{
|
{
|
||||||
$privateKey = 'file://' . __DIR__ . '/Stubs/private.key';
|
$privateKey = 'file://' . __DIR__ . '/Stubs/private.key';
|
||||||
$encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key';
|
$encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key';
|
||||||
@ -144,7 +140,7 @@ class AuthorizationServerTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$abstractGrantReflection = new \ReflectionClass($server);
|
$abstractGrantReflection = new \ReflectionClass($server);
|
||||||
$method = $abstractGrantReflection->getMethod('newResponseType');
|
$method = $abstractGrantReflection->getMethod('getResponseType');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$responseTypeA = $method->invoke($server);
|
$responseTypeA = $method->invoke($server);
|
||||||
|
Loading…
Reference in New Issue
Block a user