File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed
Authentication/Authenticators Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -169,8 +169,11 @@ public function loggedIn(): bool
169169 /** @var IncomingRequest $request */
170170 $ request = service ('request ' );
171171
172+ /** @var AuthJWT $config */
173+ $ config = config ('AuthJWT ' );
174+
172175 return $ this ->attempt ([
173- 'token ' => $ request ->getHeaderLine (config ( ' Auth ' ) ->authenticatorHeader [ ' jwt ' ] ),
176+ 'token ' => $ request ->getHeaderLine ($ config ->authenticatorHeader ),
174177 ])->isOK ();
175178 }
176179
Original file line number Diff line number Diff line change @@ -99,7 +99,6 @@ class Auth extends BaseConfig
9999 */
100100 public array $ authenticatorHeader = [
101101 'tokens ' => 'Authorization ' ,
102- 'jwt ' => 'Authorization ' ,
103102 ];
104103
105104 /**
Original file line number Diff line number Diff line change 1111 */
1212class AuthJWT extends BaseConfig
1313{
14+ /**
15+ * --------------------------------------------------------------------
16+ * Name of Authenticator Header
17+ * --------------------------------------------------------------------
18+ * The name of Header that the Authorization token should be found.
19+ * According to the specs, this should be `Authorization`, but rare
20+ * circumstances might need a different header.
21+ */
22+ public string $ authenticatorHeader = 'Authorization ' ;
23+
1424 /**
1525 * The payload items that all JWT have.
1626 *
Original file line number Diff line number Diff line change 1010use CodeIgniter \HTTP \Response ;
1111use CodeIgniter \HTTP \ResponseInterface ;
1212use CodeIgniter \Shield \Authentication \Authenticators \JWT ;
13+ use CodeIgniter \Shield \Config \AuthJWT ;
1314use Config \Services ;
1415
1516/**
@@ -65,8 +66,11 @@ private function getTokenFromHeader(RequestInterface $request): string
6566 {
6667 assert ($ request instanceof IncomingRequest);
6768
69+ /** @var AuthJWT $config */
70+ $ config = config ('AuthJWT ' );
71+
6872 $ tokenHeader = $ request ->getHeaderLine (
69- setting ( ' Auth. authenticatorHeader' )[ ' jwt ' ] ?? 'Authorization '
73+ $ config -> authenticatorHeader ?? 'Authorization '
7074 );
7175
7276 if (strpos ($ tokenHeader , 'Bearer ' ) === 0 ) {
You can’t perform that action at this time.
0 commit comments