Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use short classname for config() #796

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Authentication/Authenticators/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function __construct(UserModel $provider)
*/
public function attempt(array $credentials): Result
{
$config = config(AuthJWT::class);
/** @var AuthJWT $config */
$config = config('AuthJWT');

/** @var IncomingRequest $request */
$request = service('request');
Expand Down Expand Up @@ -142,7 +143,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 +197,8 @@ public function loggedIn(): bool
/** @var IncomingRequest $request */
$request = service('request');

$config = config(AuthJWT::class);
/** @var AuthJWT $config */
$config = config('AuthJWT');

return $this->attempt([
'token' => $request->getHeaderLine($config->authenticatorHeader),
Expand Down
6 changes: 4 additions & 2 deletions src/Authentication/JWT/Adapters/FirebaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public function decode(string $encodedToken, $keyset): stdClass
*/
private function createKeysForDecode($keyset)
{
$config = config(AuthJWT::class);
/** @var AuthJWT $config */
$config = config('AuthJWT');

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

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

if (isset($config->keys[$keyset][0]['secret'])) {
$key = $config->keys[$keyset][0]['secret'];
Expand Down
3 changes: 2 additions & 1 deletion src/Authentication/JWT/JWSEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function encode(
'Cannot pass $claims[\'exp\'] and $ttl at the same time.'
);

$config = config(AuthJWT::class);
/** @var AuthJWT $config */
$config = config('AuthJWT');

$payload = array_merge(
$config->defaultClaims,
Expand Down
3 changes: 2 additions & 1 deletion src/Filters/JWTAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private function getTokenFromHeader(RequestInterface $request): string
{
assert($request instanceof IncomingRequest);

$config = config(AuthJWT::class);
/** @var AuthJWT $config */
$config = config('AuthJWT');

$tokenHeader = $request->getHeaderLine(
$config->authenticatorHeader ?? 'Authorization'
Expand Down
2 changes: 1 addition & 1 deletion src/Models/BaseModel.php
Original file line number Diff line number Diff line change
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
Loading