Skip to content

Commit

Permalink
fix: use short classname for config()
Browse files Browse the repository at this point in the history
If FQCN is specified, devs cannot override.
  • Loading branch information
kenjis committed Aug 24, 2023
1 parent 970c67e commit 9dbb6e5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src/Authentication/Authenticators/JWT.php
Expand Up @@ -10,7 +10,6 @@
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
use CodeIgniter\Shield\Authentication\JWTManager;
use CodeIgniter\Shield\Config\Auth;
use CodeIgniter\Shield\Config\AuthJWT;
use CodeIgniter\Shield\Entities\User;
use CodeIgniter\Shield\Exceptions\RuntimeException;
use CodeIgniter\Shield\Models\TokenLoginModel;
Expand Down Expand Up @@ -61,7 +60,7 @@ public function __construct(UserModel $provider)
*/
public function attempt(array $credentials): Result
{
$config = config(AuthJWT::class);
$config = config('AuthJWT');

/** @var IncomingRequest $request */
$request = service('request');
Expand Down Expand Up @@ -142,7 +141,7 @@ public function check(array $credentials): Result
'success' => false,
'reason' => lang(
'Auth.noToken',
[config(AuthJWT::class)->authenticatorHeader]
[config('AuthJWT')->authenticatorHeader]
),
]);
}
Expand Down Expand Up @@ -196,7 +195,7 @@ public function loggedIn(): bool
/** @var IncomingRequest $request */
$request = service('request');

$config = config(AuthJWT::class);
$config = config('AuthJWT');

return $this->attempt([
'token' => $request->getHeaderLine($config->authenticatorHeader),
Expand Down
5 changes: 2 additions & 3 deletions src/Authentication/JWT/Adapters/FirebaseAdapter.php
Expand Up @@ -6,7 +6,6 @@

use CodeIgniter\Shield\Authentication\JWT\Exceptions\InvalidTokenException;
use CodeIgniter\Shield\Authentication\JWT\JWSAdapterInterface;
use CodeIgniter\Shield\Config\AuthJWT;
use CodeIgniter\Shield\Exceptions\InvalidArgumentException as ShieldInvalidArgumentException;
use CodeIgniter\Shield\Exceptions\LogicException as ShieldLogicException;
use DomainException;
Expand Down Expand Up @@ -79,7 +78,7 @@ public function decode(string $encodedToken, $keyset): stdClass
*/
private function createKeysForDecode($keyset)
{
$config = config(AuthJWT::class);
$config = config('AuthJWT');

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

Expand Down Expand Up @@ -127,7 +126,7 @@ public function encode(array $payload, $keyset, ?array $headers = null): string
*/
private function createKeysForEncode($keyset): array
{
$config = config(AuthJWT::class);
$config = config('AuthJWT');

if (isset($config->keys[$keyset][0]['secret'])) {
$key = $config->keys[$keyset][0]['secret'];
Expand Down
3 changes: 1 addition & 2 deletions src/Authentication/JWT/JWSEncoder.php
Expand Up @@ -6,7 +6,6 @@

use CodeIgniter\I18n\Time;
use CodeIgniter\Shield\Authentication\JWT\Adapters\FirebaseAdapter;
use CodeIgniter\Shield\Config\AuthJWT;

class JWSEncoder
{
Expand Down Expand Up @@ -39,7 +38,7 @@ public function encode(
'Cannot pass $claims[\'exp\'] and $ttl at the same time.'
);

$config = config(AuthJWT::class);
$config = config('AuthJWT');

$payload = array_merge(
$config->defaultClaims,
Expand Down
3 changes: 1 addition & 2 deletions src/Filters/JWTAuth.php
Expand Up @@ -10,7 +10,6 @@
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
use CodeIgniter\Shield\Config\AuthJWT;
use Config\Services;

/**
Expand Down Expand Up @@ -59,7 +58,7 @@ private function getTokenFromHeader(RequestInterface $request): string
{
assert($request instanceof IncomingRequest);

$config = config(AuthJWT::class);
$config = config('AuthJWT');

$tokenHeader = $request->getHeaderLine(
$config->authenticatorHeader ?? 'Authorization'
Expand Down
2 changes: 1 addition & 1 deletion src/Models/BaseModel.php
Expand Up @@ -20,7 +20,7 @@ abstract class BaseModel extends Model

public function __construct()
{
$this->authConfig = config(Auth::class);
$this->authConfig = config('Auth');

if ($this->authConfig->DBGroup !== null) {
$this->DBGroup = $this->authConfig->DBGroup;
Expand Down

0 comments on commit 9dbb6e5

Please sign in to comment.