1717use OxidEsales \EshopCommunity \Core \Registry ;
1818use OxidEsales \GraphQL \Base \Exception \UnableToParseToken ;
1919use OxidEsales \GraphQL \Base \Service \JwtConfigurationBuilder ;
20+ use OxidEsales \GraphQL \Base \Service \RefreshTokenServiceInterface ;
2021use OxidEsales \GraphQL \Base \Service \TokenValidator ;
2122
2223use function apache_request_headers ;
@@ -41,7 +42,7 @@ public function __construct(
4142 */
4243 public function getAuthToken (): ?UnencryptedToken
4344 {
44- $ authHeader = $ this ->getAuthorizationHeader ();
45+ $ authHeader = $ this ->getAuthorizationHeader () ?: $ this -> getAuthCookie () ;
4546
4647 if ($ authHeader === null ) {
4748 return null ;
@@ -64,6 +65,11 @@ public function getAuthToken(): ?UnencryptedToken
6465 throw new UnableToParseToken ();
6566 }
6667
68+ // using refresh token might not be necessary
69+ // if ($authHeader === $this->getAuthCookie()) {
70+ // $token = $this->refreshTokenService->refreshTokenCookie($token);
71+ // }
72+
6773 $ this ->tokenValidator ->validateToken ($ token );
6874
6975 return $ token ;
@@ -146,10 +152,6 @@ private function getAuthorizationHeader(): ?string
146152 return $ value ;
147153 }
148154
149- if ($ authCookie = $ this ->getAuthCookie ()) {
150- return 'Bearer ' . $ authCookie ;
151- }
152-
153155 if (function_exists ('apache_request_headers ' )) {
154156 $ headers = apache_request_headers ();
155157
@@ -167,7 +169,9 @@ private function getAuthorizationHeader(): ?string
167169
168170 private function getAuthCookie (): ?string
169171 {
170- return (string ) Registry::getUtilsServer ()->getOxCookie ('oxapi_jwt ' );
172+ $ authCookie = (string ) Registry::getUtilsServer ()->getOxCookie ('oxapi_jwt ' );
173+ // var_dump($authCookie);
174+ return $ authCookie ? 'Bearer ' . $ authCookie : null ;
171175 }
172176
173177 private function getRegularHeaderValue (): ?string
0 commit comments