Skip to content

Commit 974600b

Browse files
committed
bug #202 Fix Ci (ajgarlag)
This PR was squashed before being merged into the 0.9-dev branch. Discussion ---------- Fix Ci - Fix CS - Fix failing tests related to thephpleague/oauth2-server#1298 Commits ------- 9dfd8cc Fix tests 568c7de Fix CS
2 parents 44272ff + 9dfd8cc commit 974600b

18 files changed

+32
-32
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-openssl": "*",
2121
"doctrine/doctrine-bundle": "^2.8.0",
2222
"doctrine/orm": "^2.14|^3.0",
23-
"league/oauth2-server": "^9",
23+
"league/oauth2-server": "^9.0.1",
2424
"nyholm/psr7": "^1.4",
2525
"psr/http-factory": "^1.0",
2626
"symfony/event-dispatcher": "^5.4|^6.2|^7.0",

src/Command/ClearExpiredTokensCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class ClearExpiredTokensCommand extends Command
3535
public function __construct(
3636
AccessTokenManagerInterface $accessTokenManager,
3737
RefreshTokenManagerInterface $refreshTokenManager,
38-
AuthorizationCodeManagerInterface $authorizationCodeManager
38+
AuthorizationCodeManagerInterface $authorizationCodeManager,
3939
) {
4040
parent::__construct();
4141

src/Controller/AuthorizationController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(
6868
ClientManagerInterface $clientManager,
6969
HttpMessageFactoryInterface $httpMessageFactory,
7070
HttpFoundationFactoryInterface $httpFoundationFactory,
71-
ResponseFactoryInterface $responseFactory
71+
ResponseFactoryInterface $responseFactory,
7272
) {
7373
$this->server = $server;
7474
$this->eventDispatcher = $eventDispatcher;

src/Controller/TokenController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(
4747
HttpMessageFactoryInterface $httpMessageFactory,
4848
HttpFoundationFactoryInterface $httpFoundationFactory,
4949
ResponseFactoryInterface $responseFactory,
50-
EventDispatcherInterface $eventDispatcher
50+
EventDispatcherInterface $eventDispatcher,
5151
) {
5252
$this->server = $server;
5353
$this->httpMessageFactory = $httpMessageFactory;

src/Manager/Doctrine/ClientManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class ClientManager implements ClientManagerInterface
3939
public function __construct(
4040
EntityManagerInterface $entityManager,
4141
EventDispatcherInterface $dispatcher,
42-
string $clientFqcn
42+
string $clientFqcn,
4343
) {
4444
$this->entityManager = $entityManager;
4545
$this->dispatcher = $dispatcher;

src/Model/AccessToken.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
\DateTimeInterface $expiry,
4949
ClientInterface $client,
5050
?string $userIdentifier,
51-
array $scopes
51+
array $scopes,
5252
) {
5353
$this->identifier = $identifier;
5454
$this->expiry = $expiry;

src/Model/AuthorizationCode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
\DateTimeInterface $expiry,
4949
ClientInterface $client,
5050
?string $userIdentifier,
51-
array $scopes
51+
array $scopes,
5252
) {
5353
$this->identifier = $identifier;
5454
$this->expiry = $expiry;

src/Repository/AccessTokenRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class AccessTokenRepository implements AccessTokenRepositoryInterface
3535
public function __construct(
3636
AccessTokenManagerInterface $accessTokenManager,
3737
ClientManagerInterface $clientManager,
38-
ScopeConverterInterface $scopeConverter
38+
ScopeConverterInterface $scopeConverter,
3939
) {
4040
$this->accessTokenManager = $accessTokenManager;
4141
$this->clientManager = $clientManager;

src/Repository/AuthCodeRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class AuthCodeRepository implements AuthCodeRepositoryInterface
3434
public function __construct(
3535
AuthorizationCodeManagerInterface $authorizationCodeManager,
3636
ClientManagerInterface $clientManager,
37-
ScopeConverterInterface $scopeConverter
37+
ScopeConverterInterface $scopeConverter,
3838
) {
3939
$this->authorizationCodeManager = $authorizationCodeManager;
4040
$this->clientManager = $clientManager;

src/Repository/RefreshTokenRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class RefreshTokenRepository implements RefreshTokenRepositoryInterface
2626

2727
public function __construct(
2828
RefreshTokenManagerInterface $refreshTokenManager,
29-
AccessTokenManagerInterface $accessTokenManager
29+
AccessTokenManagerInterface $accessTokenManager,
3030
) {
3131
$this->refreshTokenManager = $refreshTokenManager;
3232
$this->accessTokenManager = $accessTokenManager;

src/Repository/ScopeRepository.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
ScopeManagerInterface $scopeManager,
4545
ClientManagerInterface $clientManager,
4646
ScopeConverterInterface $scopeConverter,
47-
EventDispatcherInterface $eventDispatcher
47+
EventDispatcherInterface $eventDispatcher,
4848
) {
4949
$this->scopeManager = $scopeManager;
5050
$this->clientManager = $clientManager;
@@ -73,7 +73,7 @@ public function finalizeScopes(
7373
string $grantType,
7474
ClientEntityInterface $clientEntity,
7575
string|int|null $userIdentifier = null,
76-
?string $authCodeId = null
76+
?string $authCodeId = null,
7777
): array {
7878
/** @var AbstractClient $client */
7979
$client = $this->clientManager->find($clientEntity->getIdentifier());

src/Repository/UserRepository.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class UserRepository implements UserRepositoryInterface
3535
public function __construct(
3636
ClientManagerInterface $clientManager,
3737
EventDispatcherInterface $eventDispatcher,
38-
UserConverterInterface $userConverter
38+
UserConverterInterface $userConverter,
3939
) {
4040
$this->clientManager = $clientManager;
4141
$this->eventDispatcher = $eventDispatcher;
@@ -46,7 +46,7 @@ public function getUserEntityByUserCredentials(
4646
string $username,
4747
string $password,
4848
string $grantType,
49-
ClientEntityInterface $clientEntity
49+
ClientEntityInterface $clientEntity,
5050
): ?UserEntityInterface {
5151
/** @var AbstractClient $client */
5252
$client = $this->clientManager->find($clientEntity->getIdentifier());

src/Security/Authentication/Token/OAuth2Token.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020
string $accessTokenId,
2121
string $oauthClientId,
2222
array $scopes,
23-
string $rolePrefix
23+
string $rolePrefix,
2424
) {
2525
$this->setAttribute('access_token_id', $accessTokenId);
2626
$this->setAttribute('oauth_client_id', $oauthClientId);

src/Security/Authenticator/OAuth2Authenticator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
HttpMessageFactoryInterface $httpMessageFactory,
4646
ResourceServer $resourceServer,
4747
UserProviderInterface $userProvider,
48-
string $rolePrefix
48+
string $rolePrefix,
4949
) {
5050
$this->httpMessageFactory = $httpMessageFactory;
5151
$this->resourceServer = $resourceServer;

tests/Fixtures/FixtureFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function initializeFixtures(
7676
ClientManagerInterface $clientManager,
7777
AccessTokenManagerInterface $accessTokenManager,
7878
RefreshTokenManagerInterface $refreshTokenManager,
79-
AuthorizationCodeManagerInterface $authCodeManager
79+
AuthorizationCodeManagerInterface $authCodeManager,
8080
): void {
8181
foreach (self::createScopes() as $scope) {
8282
$scopeManager->save($scope);

tests/Integration/AbstractIntegrationTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected function handleResourceRequest(ServerRequestInterface $serverRequest):
223223
return $serverRequest;
224224
}
225225

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

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

237237
$response = $this->authorizationServer->completeAuthorizationRequest($authRequest, $response);
238238
} catch (OAuthServerException $e) {
239-
$response = $e->generateHttpResponse($response);
239+
$response = $e->generateHttpResponse($response, $isImplicitGrantFlow);
240240
}
241241

242242
return $response;
@@ -268,7 +268,7 @@ private function createAuthorizationServer(
268268
AccessTokenRepositoryInterface $accessTokenRepository,
269269
RefreshTokenRepositoryInterface $refreshTokenRepository,
270270
UserRepositoryInterface $userRepository,
271-
AuthCodeRepositoryInterface $authCodeRepository
271+
AuthCodeRepositoryInterface $authCodeRepository,
272272
): AuthorizationServer {
273273
$authorizationServer = new AuthorizationServer(
274274
$clientRepository,

tests/Integration/AuthorizationServerTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ public function testSuccessfulImplicitRequest(): void
711711
'client_id' => 'foo',
712712
]);
713713

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

tests/Unit/ExtensionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function grantsProvider(): iterable
7070
*/
7171
public function testAuthCodeGrantDisableRequireCodeChallengeForPublicClientsConfig(
7272
?bool $requireCodeChallengeForPublicClients,
73-
bool $shouldTheRequirementBeDisabled
73+
bool $shouldTheRequirementBeDisabled,
7474
): void {
7575
$container = new ContainerBuilder();
7676

0 commit comments

Comments
 (0)