Skip to content

Commit

Permalink
Merge pull request #4 from ronvanderheijden/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
ronvanderheijden authored Mar 17, 2021
2 parents a1b2b4f + 1abfb67 commit e4c6d20
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
phpunit.xml export-ignore
.github/ export-ignore
example/ export-ignore
tests/ export-ignore
esc.php export-ignore
ecs.php export-ignore
15 changes: 15 additions & 0 deletions src/ClaimExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@

class ClaimExtractor
{
/**
* @var ClaimSetInterface[]
*/
protected array $claimSets;

/**
* @param ClaimSetInterface[] $claimSets
* @throws ProtectedScopeException
*/
public function __construct(ClaimSetInterface ...$claimSets)
{
$this
Expand All @@ -26,6 +33,9 @@ public function __construct(ClaimSetInterface ...$claimSets)
}
}

/**
* @return string[]
*/
public function getProtectedClaims(): array
{
return ['profile', 'email', 'address', 'phone'];
Expand Down Expand Up @@ -54,6 +64,11 @@ public function hasClaimSet(string $scope): bool
return array_key_exists($scope, $this->claimSets);
}

/**
* @param string[]|ScopeEntityInterface[] $scopes
* @param string[] $claims
* @return string[]
*/
public function extract(array $scopes, array $claims): array
{
$extracted = [];
Expand Down
3 changes: 3 additions & 0 deletions src/Claims/Claimable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@

interface Claimable
{
/**
* @return string[]
*/
public function getClaims(): array;
}
9 changes: 9 additions & 0 deletions src/Claims/Traits/WithClaims.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@

trait WithClaims
{
/**
* @param string[] $claims
*/
protected array $claims;

/**
* @return string[]
*/
public function getClaims(): array
{
return $this->claims;
}

/**
* @param string[] $claims
*/
public function setClaims(array $claims): void
{
$this->claims = $claims;
Expand Down
5 changes: 5 additions & 0 deletions src/Claims/Traits/WithScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public function getScope(): string
{
return $this->scope;
}

public function setScope(string $scope): void
{
$this->scope = $scope;
}
}
3 changes: 3 additions & 0 deletions src/Entities/IdentityEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class IdentityEntity implements IdentityEntityInterface
use EntityTrait;
use WithClaims;

/**
* @return string[]
*/
public function getClaims(): array
{
/**
Expand Down
24 changes: 19 additions & 5 deletions src/Laravel/config/openid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

declare(strict_types=1);

use OpenIDConnect\Repositories\IdentityRepository;
use OpenIDConnect\Repositories\ScopeRepository;

return [
'passport' => [

/**
* Place your Passport and OpenID Connect scopes here.
* To receive an `id_token, you should at least provide the openid scope.
*/
'tokens_can' => [
'openid' => 'Enable OpenID Connect',
'profile' => 'Information about your profile',
Expand All @@ -17,14 +19,26 @@
],
],

/**
* Place your custom claim sets here.
*/
'custom_claim_sets' => [
// 'login' => [
// 'last-login',
// ],
// 'company' => [
// 'company_name',
// 'company_address',
// 'company_phone',
// 'company_email',
// ],
],

/**
* You can override the repositories below.
*/
'repositories' => [
'identity' => IdentityRepository::class,
'scope' => ScopeRepository::class,
'identity' => \OpenIDConnect\Repositories\IdentityRepository::class,
'scope' => \OpenIDConnect\Repositories\ScopeRepository::class,
],
];

0 comments on commit e4c6d20

Please sign in to comment.