diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index 251c782d..93e7eb51 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -145,7 +145,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant ), ]); - $htmlResponse = new HtmlResponse($this->accessTokenRepository); + $htmlResponse = new HtmlResponse(); $htmlResponse->setStatusCode(403); $htmlResponse->setHtml($html); @@ -163,7 +163,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant ), ]); - $htmlResponse = new HtmlResponse($this->accessTokenRepository); + $htmlResponse = new HtmlResponse(); $htmlResponse->setStatusCode(200); $htmlResponse->setHtml($html); $htmlResponse->setHeader('set-cookie', sprintf( @@ -215,7 +215,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant ) ); - $response = new RedirectResponse($this->accessTokenRepository); + $response = new RedirectResponse(); $response->setRedirectUri( $this->makeRedirectUri( $redirectUri, diff --git a/src/Grant/ImplicitGrant.php b/src/Grant/ImplicitGrant.php index 2fe4a455..6f7b1301 100644 --- a/src/Grant/ImplicitGrant.php +++ b/src/Grant/ImplicitGrant.php @@ -141,7 +141,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant ), ]); - $htmlResponse = new HtmlResponse($this->accessTokenRepository); + $htmlResponse = new HtmlResponse(); $htmlResponse->setStatusCode(403); $htmlResponse->setHtml($html); @@ -159,7 +159,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant ), ]); - $htmlResponse = new HtmlResponse($this->accessTokenRepository); + $htmlResponse = new HtmlResponse(); $htmlResponse->setStatusCode(200); $htmlResponse->setHtml($html); $htmlResponse->setHeader('set-cookie', sprintf( @@ -201,7 +201,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant $redirectPayload['token_type'] = 'bearer'; $redirectPayload['expires_in'] = time() - $accessToken->getExpiryDateTime()->getTimestamp(); - $response = new RedirectResponse($this->accessTokenRepository); + $response = new RedirectResponse(); $response->setRedirectUri( $this->makeRedirectUri( $redirectUri, diff --git a/src/ResponseTypes/AbstractResponseType.php b/src/ResponseTypes/AbstractResponseType.php index e693d85b..c42e1d87 100644 --- a/src/ResponseTypes/AbstractResponseType.php +++ b/src/ResponseTypes/AbstractResponseType.php @@ -13,7 +13,6 @@ namespace League\OAuth2\Server\ResponseTypes; use League\OAuth2\Server\CryptTrait; use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface; -use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; abstract class AbstractResponseType implements ResponseTypeInterface { @@ -29,19 +28,6 @@ abstract class AbstractResponseType implements ResponseTypeInterface */ protected $refreshToken; - /** - * @var \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface - */ - protected $accessTokenRepository; - - /** - * @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository - */ - public function __construct(AccessTokenRepositoryInterface $accessTokenRepository) - { - $this->accessTokenRepository = $accessTokenRepository; - } - /** * {@inheritdoc} */ diff --git a/tests/ResponseTypes/BearerResponseTypeTest.php b/tests/ResponseTypes/BearerResponseTypeTest.php index 3fb11168..c60426a2 100644 --- a/tests/ResponseTypes/BearerResponseTypeTest.php +++ b/tests/ResponseTypes/BearerResponseTypeTest.php @@ -90,6 +90,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase $response = $responseType->generateHttpResponse(new Response()); $json = json_decode((string) $response->getBody()); + $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); + $accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false); + $authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock); $authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key')); @@ -153,12 +156,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase public function testDetermineAccessTokenInHeaderRevokedToken() { - $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); - $accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true); - - $responseType = new BearerTokenResponse($accessTokenRepositoryMock); - $responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); - $responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key')); + $responseType = new BearerTokenResponse(); + $responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key'); + $responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key'); $client = new ClientEntity(); $client->setIdentifier('clientName'); @@ -180,6 +180,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase $response = $responseType->generateHttpResponse(new Response()); $json = json_decode((string) $response->getBody()); + $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); + $accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true); + $authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock); $authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key')); @@ -205,6 +208,8 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase $responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key')); + $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); + $authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock); $authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));