Skip to content

Commit

Permalink
[shopsys] refresh tokens for FE API (#1736)
Browse files Browse the repository at this point in the history
[shopsys] refresh tokens for FE API (#1736)
  • Loading branch information
pesektomas authored Mar 31, 2020
1 parent e997bae commit 3e9a056
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 0 additions & 4 deletions config/graphql/types/Login.types.yml

This file was deleted.

4 changes: 4 additions & 0 deletions config/graphql/types/LoginInput.types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LoginInput:
type: input-object
inherits:
- 'LoginInputDecorator'
4 changes: 4 additions & 0 deletions config/graphql/types/RefreshTokenInput.types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RefreshTokenInput:
type: input-object
inherits:
- 'RefreshTokenInputDecorator'
5 changes: 4 additions & 1 deletion config/packages/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ security:
user_identities:
id: Shopsys\FrameworkBundle\Model\Customer\User\FrontendCustomerUserProvider

frontend_api_user_identities:
id: Shopsys\FrontendApiBundle\Model\User\FrontendApiUserProvider

firewalls:
# see Shopsys\FrameworkBundle\Model\Administrator\Security\AdministratorFrontSecurityFacade
administration:
Expand All @@ -39,7 +42,7 @@ security:
invalidate_session: false
frontend_api:
pattern: ^/graphql
provider: user_identities
provider: frontend_api_user_identities
stateless: true
anonymous: true
guard:
Expand Down
5 changes: 5 additions & 0 deletions tests/FrontendApiBundle/Functional/Login/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public function testLoginMutation(): void
$responseData = $this->getResponseContentForQuery($this->getLoginQuery())['data']['Login'];
$this->assertArrayHasKey('accessToken', $responseData);
$this->assertIsString($responseData['accessToken']);
$this->assertArrayHasKey('refreshToken', $responseData);
$this->assertIsString($responseData['refreshToken']);

try {
$this->tokenFacade->getTokenByString($responseData['accessToken']);
Expand All @@ -30,6 +32,8 @@ public function testLoginMutation(): void
$authorizationResponseData = $this->getResponseContentForQuery($this->getLoginQuery(), [], ['HTTP_Authorization' => sprintf('Bearer %s', $responseData['accessToken'])])['data']['Login'];
$this->assertArrayHasKey('accessToken', $authorizationResponseData);
$this->assertIsString($authorizationResponseData['accessToken']);
$this->assertArrayHasKey('refreshToken', $authorizationResponseData);
$this->assertIsString($authorizationResponseData['refreshToken']);
}

public function testInvalidTokenException()
Expand Down Expand Up @@ -65,6 +69,7 @@ private function getLoginQuery(): string
password: "user123"
}) {
accessToken
refreshToken
}
}
';
Expand Down

0 comments on commit 3e9a056

Please sign in to comment.