diff --git a/.gitattributes b/.gitattributes index 7c02f8d..5b01116 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/src/ClaimExtractor.php b/src/ClaimExtractor.php index b1afca7..a2d6514 100644 --- a/src/ClaimExtractor.php +++ b/src/ClaimExtractor.php @@ -11,8 +11,15 @@ class ClaimExtractor { + /** + * @var ClaimSetInterface[] + */ protected array $claimSets; + /** + * @param ClaimSetInterface[] $claimSets + * @throws ProtectedScopeException + */ public function __construct(ClaimSetInterface ...$claimSets) { $this @@ -26,6 +33,9 @@ public function __construct(ClaimSetInterface ...$claimSets) } } + /** + * @return string[] + */ public function getProtectedClaims(): array { return ['profile', 'email', 'address', 'phone']; @@ -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 = []; diff --git a/src/Claims/Claimable.php b/src/Claims/Claimable.php index 60bc1d2..d975404 100644 --- a/src/Claims/Claimable.php +++ b/src/Claims/Claimable.php @@ -6,5 +6,8 @@ interface Claimable { + /** + * @return string[] + */ public function getClaims(): array; } diff --git a/src/Claims/Traits/WithClaims.php b/src/Claims/Traits/WithClaims.php index f6ed77d..69cb086 100644 --- a/src/Claims/Traits/WithClaims.php +++ b/src/Claims/Traits/WithClaims.php @@ -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; diff --git a/src/Claims/Traits/WithScope.php b/src/Claims/Traits/WithScope.php index 3941b53..0b6e103 100644 --- a/src/Claims/Traits/WithScope.php +++ b/src/Claims/Traits/WithScope.php @@ -12,4 +12,9 @@ public function getScope(): string { return $this->scope; } + + public function setScope(string $scope): void + { + $this->scope = $scope; + } } diff --git a/src/Entities/IdentityEntity.php b/src/Entities/IdentityEntity.php index 9c813e6..f8ec104 100644 --- a/src/Entities/IdentityEntity.php +++ b/src/Entities/IdentityEntity.php @@ -13,6 +13,9 @@ class IdentityEntity implements IdentityEntityInterface use EntityTrait; use WithClaims; + /** + * @return string[] + */ public function getClaims(): array { /** diff --git a/src/Laravel/config/openid.php b/src/Laravel/config/openid.php index 5dea82c..60c9845 100644 --- a/src/Laravel/config/openid.php +++ b/src/Laravel/config/openid.php @@ -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', @@ -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, ], ];