Skip to content
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 api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"gesdinet/jwt-refresh-token-bundle": "1.5.0",
"google/recaptcha": "1.3.1",
"guzzlehttp/guzzle": "7.10.0",
"knpuniversity/oauth2-client-bundle": "2.19.0",
"knpuniversity/oauth2-client-bundle": "2.20.0",
"league/oauth2-google": "4.0.1",
"lexik/jwt-authentication-bundle": "3.1.1",
"nelmio/cors-bundle": "2.6.0",
Expand Down
29 changes: 15 additions & 14 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions api/src/OAuth/JWTStateOAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ public function redirect(array $scopes = [], array $options = []): RedirectRespo
*/
#[\Override]
public function getAccessToken(array $options = []): AccessTokenInterface {
$jwt = $this->getCurrentRequest()->cookies->get(static::getCookieName($this->cookiePrefix));
$request = $this->getCurrentRequest();
$jwt = $request->cookies->get(static::getCookieName($this->cookiePrefix));
if (null === $jwt) {
throw new InvalidStateException('Expired state');
}

$actualState = $this->getCurrentRequest()->get('state');
$actualState = $request->query->get('state');

try {
if ($this->decodeStateJWT($jwt) !== $actualState) {
Expand Down
12 changes: 6 additions & 6 deletions api/tests/OAuth/JWTStateOAuth2ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testGetAccessToken() {
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down Expand Up @@ -175,7 +175,7 @@ public function testGetAccessTokenThrowsIfJWTCannotBeDecoded() {
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down Expand Up @@ -220,7 +220,7 @@ public function testGetAccessTokenThrowsIfJWTStateDoesNotMatch() {
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down Expand Up @@ -265,7 +265,7 @@ public function testGetAccessTokenThrowsIfNoMatchingStateEntryInTheDatabase() {
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down Expand Up @@ -311,7 +311,7 @@ public function testGetAccessTokenThrowsIfMultipleMatchingStateEntriesInTheDatab
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down Expand Up @@ -357,7 +357,7 @@ public function testGetAccessTokenRemovesSavedStateFromDatabase() {
$cookieBag = new InputBag();
$cookieBag->set('test_prefix_oauth_state_jwt', 'test jwt value');
$requestMock->cookies = $cookieBag;
$requestMock->method('get')->willReturn($state);
$requestMock->query = new InputBag(['state' => $state, 'code' => $state]);

$jwtEncoderMock = $this->createMock(JWTEncoderInterface::class);
$jwtEncoderMock->expects($this->once())
Expand Down