Skip to content

Commit

Permalink
add array dot support to id_claim and roles_claim (#4)
Browse files Browse the repository at this point in the history
* add array dot support to id_claim and roles_claim

* revert whitespace changes
  • Loading branch information
MuhammedAlkhudiry authored Feb 13, 2024
1 parent f546a9c commit 09278bd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Support/JwtParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JwtParser
private bool $isJwtValid = false;

private string $errorMessage = '';

private array $claims;
private string $jwt;
private string $publicKey;
private string $idClaim;
Expand Down Expand Up @@ -48,6 +48,8 @@ public function __construct(
if (!$this->validate()) {
throw new JwtValidationException($this->errorMessage);
}

$this->claims = \Arr::dot($this->parsedJwt->claims()->all());
}

private function getAlgorithmClass(): string
Expand Down Expand Up @@ -138,12 +140,12 @@ private function validate(): bool

public function getId()
{
return $this->getClaim($this->idClaim);
}
return $this->claims[$this->idClaim] ?? null;
}

public function getRoles()
{
return $this->getClaim($this->rolesClaim);
return $this->claims[$this->rolesClaim] ?? null;
}

/**
Expand Down

0 comments on commit 09278bd

Please sign in to comment.