mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-01 01:40:21 +05:30
Merge branch 'repository_on_response' of https://github.com/juliangut/oauth2-server into juliangut-repository_on_response
# Conflicts: # tests/ResponseTypes/BearerResponseTypeTest.php
This commit is contained in:
commit
39281a6f38
@ -145,7 +145,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$htmlResponse = new HtmlResponse($this->accessTokenRepository);
|
$htmlResponse = new HtmlResponse();
|
||||||
$htmlResponse->setStatusCode(403);
|
$htmlResponse->setStatusCode(403);
|
||||||
$htmlResponse->setHtml($html);
|
$htmlResponse->setHtml($html);
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$htmlResponse = new HtmlResponse($this->accessTokenRepository);
|
$htmlResponse = new HtmlResponse();
|
||||||
$htmlResponse->setStatusCode(200);
|
$htmlResponse->setStatusCode(200);
|
||||||
$htmlResponse->setHtml($html);
|
$htmlResponse->setHtml($html);
|
||||||
$htmlResponse->setHeader('set-cookie', sprintf(
|
$htmlResponse->setHeader('set-cookie', sprintf(
|
||||||
@ -215,7 +215,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = new RedirectResponse($this->accessTokenRepository);
|
$response = new RedirectResponse();
|
||||||
$response->setRedirectUri(
|
$response->setRedirectUri(
|
||||||
$this->makeRedirectUri(
|
$this->makeRedirectUri(
|
||||||
$redirectUri,
|
$redirectUri,
|
||||||
|
@ -141,7 +141,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$htmlResponse = new HtmlResponse($this->accessTokenRepository);
|
$htmlResponse = new HtmlResponse();
|
||||||
$htmlResponse->setStatusCode(403);
|
$htmlResponse->setStatusCode(403);
|
||||||
$htmlResponse->setHtml($html);
|
$htmlResponse->setHtml($html);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$htmlResponse = new HtmlResponse($this->accessTokenRepository);
|
$htmlResponse = new HtmlResponse();
|
||||||
$htmlResponse->setStatusCode(200);
|
$htmlResponse->setStatusCode(200);
|
||||||
$htmlResponse->setHtml($html);
|
$htmlResponse->setHtml($html);
|
||||||
$htmlResponse->setHeader('set-cookie', sprintf(
|
$htmlResponse->setHeader('set-cookie', sprintf(
|
||||||
@ -201,7 +201,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
$redirectPayload['token_type'] = 'bearer';
|
$redirectPayload['token_type'] = 'bearer';
|
||||||
$redirectPayload['expires_in'] = time() - $accessToken->getExpiryDateTime()->getTimestamp();
|
$redirectPayload['expires_in'] = time() - $accessToken->getExpiryDateTime()->getTimestamp();
|
||||||
|
|
||||||
$response = new RedirectResponse($this->accessTokenRepository);
|
$response = new RedirectResponse();
|
||||||
$response->setRedirectUri(
|
$response->setRedirectUri(
|
||||||
$this->makeRedirectUri(
|
$this->makeRedirectUri(
|
||||||
$redirectUri,
|
$redirectUri,
|
||||||
|
@ -13,7 +13,6 @@ namespace League\OAuth2\Server\ResponseTypes;
|
|||||||
use League\OAuth2\Server\CryptTrait;
|
use League\OAuth2\Server\CryptTrait;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
|
||||||
|
|
||||||
abstract class AbstractResponseType implements ResponseTypeInterface
|
abstract class AbstractResponseType implements ResponseTypeInterface
|
||||||
{
|
{
|
||||||
@ -29,19 +28,6 @@ abstract class AbstractResponseType implements ResponseTypeInterface
|
|||||||
*/
|
*/
|
||||||
protected $refreshToken;
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -90,6 +90,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$response = $responseType->generateHttpResponse(new Response());
|
$response = $responseType->generateHttpResponse(new Response());
|
||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
|
|
||||||
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
|
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(false);
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
@ -153,12 +156,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testDetermineAccessTokenInHeaderRevokedToken()
|
public function testDetermineAccessTokenInHeaderRevokedToken()
|
||||||
{
|
{
|
||||||
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
$responseType = new BearerTokenResponse();
|
||||||
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true);
|
$responseType->setPrivateKeyPath('file://' . __DIR__ . '/../Stubs/private.key');
|
||||||
|
$responseType->setPublicKeyPath('file://' . __DIR__ . '/../Stubs/public.key');
|
||||||
$responseType = new BearerTokenResponse($accessTokenRepositoryMock);
|
|
||||||
$responseType->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
|
||||||
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
|
||||||
|
|
||||||
$client = new ClientEntity();
|
$client = new ClientEntity();
|
||||||
$client->setIdentifier('clientName');
|
$client->setIdentifier('clientName');
|
||||||
@ -180,6 +180,9 @@ class BearerResponseTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$response = $responseType->generateHttpResponse(new Response());
|
$response = $responseType->generateHttpResponse(new Response());
|
||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
|
|
||||||
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
|
$accessTokenRepositoryMock->method('isAccessTokenRevoked')->willReturn(true);
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.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->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
$responseType->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
|
||||||
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
||||||
|
|
||||||
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
$authorizationValidator = new BearerTokenValidator($accessTokenRepositoryMock);
|
||||||
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
$authorizationValidator->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key'));
|
||||||
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
$authorizationValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key'));
|
||||||
|
Loading…
Reference in New Issue
Block a user