Skip to content

Commit

Permalink
Merge pull request #27 from alecpl/dev/get-claims-with-scopes
Browse files Browse the repository at this point in the history
Add scope filter to getClaims()
  • Loading branch information
jeremy379 authored Sep 9, 2024
2 parents 6c721ca + 65aa80a commit 4a22ec9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Claims/Claimable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
interface Claimable
{
/**
* @param string[] $scopes Optional scope filter
*
* @return string[]
*/
public function getClaims(): array;
public function getClaims(array $scopes = []): array;
}
4 changes: 3 additions & 1 deletion src/Claims/Traits/WithClaims.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ trait WithClaims
protected array $claims;

/**
* @param string[] $scopes Optional scope filter
*
* @return string[]
*/
public function getClaims(): array
public function getClaims(array $scopes = []): array
{
return $this->claims;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Entities/IdentityEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class IdentityEntity implements IdentityEntityInterface
use WithClaims;

/**
* @param string[] $scopes Optional scope filter
*
* @return string[]
*/
public function getClaims(): array
public function getClaims(array $scopes = []): array
{
/**
* For a complete list of default claim sets
Expand Down
2 changes: 1 addition & 1 deletion src/IdTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function getExtraParams(AccessTokenEntityInterface $accessToken): arra

$claims = $this->claimExtractor->extract(
$scopes,
$user->getClaims(),
$user->getClaims(explode(' ', $params['scope'])),
);

foreach ($claims as $claimName => $claimValue) {
Expand Down

0 comments on commit 4a22ec9

Please sign in to comment.