mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
remove access token repository from response types
This commit is contained in:
parent
9533595394
commit
e513b42117
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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}
|
||||
*/
|
||||
|
@ -18,9 +18,7 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGenerateHttpResponse()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
|
||||
@ -62,10 +60,7 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDetermineAccessTokenInHeaderValidToken()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
|
||||
@ -89,6 +84,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->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
@ -152,10 +150,7 @@ 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 = new BearerTokenResponse();
|
||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
|
||||
@ -179,6 +174,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->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
@ -198,12 +196,12 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDetermineAccessTokenInHeaderInvalidToken()
|
||||
{
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
||||
$responseType = new BearerTokenResponse();
|
||||
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
|
||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||
|
||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||
$authorizationValidator->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||
$authorizationValidator->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||
|
Loading…
Reference in New Issue
Block a user