Skip to content

Commit 23286e1

Browse files
committed
fix: use short classname for config()
If FQCN is specified, devs cannot override.
1 parent 970c67e commit 23286e1

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/Authentication/Authenticators/JWT.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function __construct(UserModel $provider)
6161
*/
6262
public function attempt(array $credentials): Result
6363
{
64-
$config = config(AuthJWT::class);
64+
/** @var AuthJWT $config */
65+
$config = config('AuthJWT');
6566

6667
/** @var IncomingRequest $request */
6768
$request = service('request');
@@ -142,7 +143,7 @@ public function check(array $credentials): Result
142143
'success' => false,
143144
'reason' => lang(
144145
'Auth.noToken',
145-
[config(AuthJWT::class)->authenticatorHeader]
146+
[config('AuthJWT')->authenticatorHeader]
146147
),
147148
]);
148149
}
@@ -196,7 +197,8 @@ public function loggedIn(): bool
196197
/** @var IncomingRequest $request */
197198
$request = service('request');
198199

199-
$config = config(AuthJWT::class);
200+
/** @var AuthJWT $config */
201+
$config = config('AuthJWT');
200202

201203
return $this->attempt([
202204
'token' => $request->getHeaderLine($config->authenticatorHeader),

src/Authentication/JWT/Adapters/FirebaseAdapter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public function decode(string $encodedToken, $keyset): stdClass
7979
*/
8080
private function createKeysForDecode($keyset)
8181
{
82-
$config = config(AuthJWT::class);
82+
/** @var AuthJWT $config */
83+
$config = config('AuthJWT');
8384

8485
$configKeys = $config->keys[$keyset];
8586

@@ -127,7 +128,8 @@ public function encode(array $payload, $keyset, ?array $headers = null): string
127128
*/
128129
private function createKeysForEncode($keyset): array
129130
{
130-
$config = config(AuthJWT::class);
131+
/** @var AuthJWT $config */
132+
$config = config('AuthJWT');
131133

132134
if (isset($config->keys[$keyset][0]['secret'])) {
133135
$key = $config->keys[$keyset][0]['secret'];

src/Authentication/JWT/JWSEncoder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function encode(
3939
'Cannot pass $claims[\'exp\'] and $ttl at the same time.'
4040
);
4141

42-
$config = config(AuthJWT::class);
42+
/** @var AuthJWT $config */
43+
$config = config('AuthJWT');
4344

4445
$payload = array_merge(
4546
$config->defaultClaims,

src/Filters/JWTAuth.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ private function getTokenFromHeader(RequestInterface $request): string
5959
{
6060
assert($request instanceof IncomingRequest);
6161

62-
$config = config(AuthJWT::class);
62+
/** @var AuthJWT $config */
63+
$config = config('AuthJWT');
6364

6465
$tokenHeader = $request->getHeaderLine(
6566
$config->authenticatorHeader ?? 'Authorization'

src/Models/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class BaseModel extends Model
2020

2121
public function __construct()
2222
{
23-
$this->authConfig = config(Auth::class);
23+
$this->authConfig = config('Auth');
2424

2525
if ($this->authConfig->DBGroup !== null) {
2626
$this->DBGroup = $this->authConfig->DBGroup;

0 commit comments

Comments
 (0)