Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ci #202

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ext-openssl": "*",
"doctrine/doctrine-bundle": "^2.8.0",
"doctrine/orm": "^2.14|^3.0",
"league/oauth2-server": "^9",
"league/oauth2-server": "^9.0.1",
"nyholm/psr7": "^1.4",
"psr/http-factory": "^1.0",
"symfony/event-dispatcher": "^5.4|^6.2|^7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ClearExpiredTokensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class ClearExpiredTokensCommand extends Command
public function __construct(
AccessTokenManagerInterface $accessTokenManager,
RefreshTokenManagerInterface $refreshTokenManager,
AuthorizationCodeManagerInterface $authorizationCodeManager
AuthorizationCodeManagerInterface $authorizationCodeManager,
) {
parent::__construct();

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(
ClientManagerInterface $clientManager,
HttpMessageFactoryInterface $httpMessageFactory,
HttpFoundationFactoryInterface $httpFoundationFactory,
ResponseFactoryInterface $responseFactory
ResponseFactoryInterface $responseFactory,
) {
$this->server = $server;
$this->eventDispatcher = $eventDispatcher;
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/TokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
HttpMessageFactoryInterface $httpMessageFactory,
HttpFoundationFactoryInterface $httpFoundationFactory,
ResponseFactoryInterface $responseFactory,
EventDispatcherInterface $eventDispatcher
EventDispatcherInterface $eventDispatcher,
) {
$this->server = $server;
$this->httpMessageFactory = $httpMessageFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/Manager/Doctrine/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ClientManager implements ClientManagerInterface
public function __construct(
EntityManagerInterface $entityManager,
EventDispatcherInterface $dispatcher,
string $clientFqcn
string $clientFqcn,
) {
$this->entityManager = $entityManager;
$this->dispatcher = $dispatcher;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
\DateTimeInterface $expiry,
ClientInterface $client,
?string $userIdentifier,
array $scopes
array $scopes,
) {
$this->identifier = $identifier;
$this->expiry = $expiry;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/AuthorizationCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
\DateTimeInterface $expiry,
ClientInterface $client,
?string $userIdentifier,
array $scopes
array $scopes,
) {
$this->identifier = $identifier;
$this->expiry = $expiry;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AccessTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class AccessTokenRepository implements AccessTokenRepositoryInterface
public function __construct(
AccessTokenManagerInterface $accessTokenManager,
ClientManagerInterface $clientManager,
ScopeConverterInterface $scopeConverter
ScopeConverterInterface $scopeConverter,
) {
$this->accessTokenManager = $accessTokenManager;
$this->clientManager = $clientManager;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AuthCodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class AuthCodeRepository implements AuthCodeRepositoryInterface
public function __construct(
AuthorizationCodeManagerInterface $authorizationCodeManager,
ClientManagerInterface $clientManager,
ScopeConverterInterface $scopeConverter
ScopeConverterInterface $scopeConverter,
) {
$this->authorizationCodeManager = $authorizationCodeManager;
$this->clientManager = $clientManager;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/RefreshTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class RefreshTokenRepository implements RefreshTokenRepositoryInterface

public function __construct(
RefreshTokenManagerInterface $refreshTokenManager,
AccessTokenManagerInterface $accessTokenManager
AccessTokenManagerInterface $accessTokenManager,
) {
$this->refreshTokenManager = $refreshTokenManager;
$this->accessTokenManager = $accessTokenManager;
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/ScopeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
ScopeManagerInterface $scopeManager,
ClientManagerInterface $clientManager,
ScopeConverterInterface $scopeConverter,
EventDispatcherInterface $eventDispatcher
EventDispatcherInterface $eventDispatcher,
) {
$this->scopeManager = $scopeManager;
$this->clientManager = $clientManager;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function finalizeScopes(
string $grantType,
ClientEntityInterface $clientEntity,
string|int|null $userIdentifier = null,
?string $authCodeId = null
?string $authCodeId = null,
): array {
/** @var AbstractClient $client */
$client = $this->clientManager->find($clientEntity->getIdentifier());
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class UserRepository implements UserRepositoryInterface
public function __construct(
ClientManagerInterface $clientManager,
EventDispatcherInterface $eventDispatcher,
UserConverterInterface $userConverter
UserConverterInterface $userConverter,
) {
$this->clientManager = $clientManager;
$this->eventDispatcher = $eventDispatcher;
Expand All @@ -46,7 +46,7 @@ public function getUserEntityByUserCredentials(
string $username,
string $password,
string $grantType,
ClientEntityInterface $clientEntity
ClientEntityInterface $clientEntity,
): ?UserEntityInterface {
/** @var AbstractClient $client */
$client = $this->clientManager->find($clientEntity->getIdentifier());
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authentication/Token/OAuth2Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
string $accessTokenId,
string $oauthClientId,
array $scopes,
string $rolePrefix
string $rolePrefix,
) {
$this->setAttribute('access_token_id', $accessTokenId);
$this->setAttribute('oauth_client_id', $oauthClientId);
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authenticator/OAuth2Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
HttpMessageFactoryInterface $httpMessageFactory,
ResourceServer $resourceServer,
UserProviderInterface $userProvider,
string $rolePrefix
string $rolePrefix,
) {
$this->httpMessageFactory = $httpMessageFactory;
$this->resourceServer = $resourceServer;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function initializeFixtures(
ClientManagerInterface $clientManager,
AccessTokenManagerInterface $accessTokenManager,
RefreshTokenManagerInterface $refreshTokenManager,
AuthorizationCodeManagerInterface $authCodeManager
AuthorizationCodeManagerInterface $authCodeManager,
): void {
foreach (self::createScopes() as $scope) {
$scopeManager->save($scope);
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/AbstractIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected function handleResourceRequest(ServerRequestInterface $serverRequest):
return $serverRequest;
}

protected function handleAuthorizationRequest(ServerRequestInterface $serverRequest, $approved = true): ResponseInterface
protected function handleAuthorizationRequest(ServerRequestInterface $serverRequest, $approved = true, $isImplicitGrantFlow = false): ResponseInterface
{
$response = $this->psrFactory->createResponse();

Expand All @@ -236,7 +236,7 @@ protected function handleAuthorizationRequest(ServerRequestInterface $serverRequ

$response = $this->authorizationServer->completeAuthorizationRequest($authRequest, $response);
} catch (OAuthServerException $e) {
$response = $e->generateHttpResponse($response);
$response = $e->generateHttpResponse($response, $isImplicitGrantFlow);
}

return $response;
Expand Down Expand Up @@ -268,7 +268,7 @@ private function createAuthorizationServer(
AccessTokenRepositoryInterface $accessTokenRepository,
RefreshTokenRepositoryInterface $refreshTokenRepository,
UserRepositoryInterface $userRepository,
AuthCodeRepositoryInterface $authCodeRepository
AuthCodeRepositoryInterface $authCodeRepository,
): AuthorizationServer {
$authorizationServer = new AuthorizationServer(
$clientRepository,
Expand Down
22 changes: 11 additions & 11 deletions tests/Integration/AuthorizationServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ public function testSuccessfulImplicitRequest(): void
'client_id' => 'foo',
]);

$response = $this->handleAuthorizationRequest($request);
$response = $this->handleAuthorizationRequest($request, true, true);
$this->assertSame(302, $response->getStatusCode());
$responseData = [];
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_FRAGMENT), $responseData);
Expand All @@ -733,7 +733,7 @@ public function testSuccessfulImplicitRequestWithState(): void
'state' => 'quzbaz',
]);

$response = $this->handleAuthorizationRequest($request);
$response = $this->handleAuthorizationRequest($request, true, true);

$this->assertSame(302, $response->getStatusCode());
$responseData = [];
Expand All @@ -757,7 +757,7 @@ public function testSuccessfulImplicitRequestRedirectUri(): void
'redirect_uri' => 'https://example.org/oauth2/redirect-uri',
]);

$response = $this->handleAuthorizationRequest($request);
$response = $this->handleAuthorizationRequest($request, true, true);
$this->assertSame(302, $response->getStatusCode());
$responseData = [];
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_FRAGMENT), $responseData);
Expand All @@ -779,10 +779,10 @@ public function testImplicitRequestWithInvalidScope(): void
'scope' => 'non_existing',
]);

$response = $this->handleAuthorizationRequest($request);
$response = $this->handleAuthorizationRequest($request, true, true);
$this->assertSame(302, $response->getStatusCode());
$responseData = [];
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_QUERY), $responseData);
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_FRAGMENT), $responseData);

// Response assertions.
$this->assertSame('invalid_scope', $responseData['error']);
Expand All @@ -798,7 +798,7 @@ public function testImplicitRequestWithInvalidRedirectUri(): void
'redirect_uri' => 'https://example.org/oauth2/other-uri',
]);

$response = $this->handleAuthorizationRequest($request);
$response = $this->handleAuthorizationRequest($request, true, true);
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);

Expand All @@ -814,10 +814,10 @@ public function testDeniedImplicitRequest(): void
'client_id' => 'foo',
]);

$response = $this->handleAuthorizationRequest($request, false);
$response = $this->handleAuthorizationRequest($request, false, true);
$this->assertSame(302, $response->getStatusCode());
$responseData = [];
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_QUERY), $responseData);
parse_str(parse_url($response->getHeaderLine('Location'), \PHP_URL_FRAGMENT), $responseData);

// Response assertions.
$this->assertSame('access_denied', $responseData['error']);
Expand All @@ -832,7 +832,7 @@ public function testImplicitRequestWithMissingClient(): void
'client_id' => 'yolo',
]);

$response = $this->handleAuthorizationRequest($request, false);
$response = $this->handleAuthorizationRequest($request, false, true);
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);

Expand All @@ -848,7 +848,7 @@ public function testImplicitRequestWithInactiveClient(): void
'client_id' => 'baz_inactive',
]);

$response = $this->handleAuthorizationRequest($request, false);
$response = $this->handleAuthorizationRequest($request, false, true);
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);

Expand All @@ -864,7 +864,7 @@ public function testImplicitRequestWithRestrictedGrantClient(): void
'client_id' => 'qux_restricted',
]);

$response = $this->handleAuthorizationRequest($request, false);
$response = $this->handleAuthorizationRequest($request, false, true);
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function grantsProvider(): iterable
*/
public function testAuthCodeGrantDisableRequireCodeChallengeForPublicClientsConfig(
?bool $requireCodeChallengeForPublicClients,
bool $shouldTheRequirementBeDisabled
bool $shouldTheRequirementBeDisabled,
): void {
$container = new ContainerBuilder();

Expand Down