Skip to content

Commit ec9f0a8

Browse files
committed
Add new informational metadata claims
1 parent 5c64f43 commit ec9f0a8

File tree

6 files changed

+107
-2
lines changed

6 files changed

+107
-2
lines changed

UPGRADE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ and optionally a port (as in all previous module versions).
5252
- signer algorithm
5353
- entity statement duration
5454
- organization name
55+
- display name
56+
- description
57+
- keywords
5558
- contacts
5659
- logo URI
5760
- policy URI
58-
- homepage URI
61+
- information URI
62+
- homepage URI (renamed to organization_uri in draft-43)
63+
- organization URI
5964

6065
## Major impact changes
6166

config/module_oidc.php.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,21 @@ $config = [
471471
// Common federation entity parameters:
472472
// https://openid.net/specs/openid-federation-1_0.html#name-common-metadata-parameters
473473
ModuleConfig::OPTION_ORGANIZATION_NAME => null,
474+
ModuleConfig::OPTION_DISPLAY_NAME => null,
475+
ModuleConfig::OPTION_DESCRIPTION => null,
476+
ModuleConfig::OPTION_KEYWORDS => [
477+
// 'some-keyword',
478+
],
474479
ModuleConfig::OPTION_CONTACTS => [
475480
// 'John Doe [email protected]',
476481
],
477482
ModuleConfig::OPTION_LOGO_URI => null,
478483
ModuleConfig::OPTION_POLICY_URI => null,
484+
ModuleConfig::OPTION_INFORMATION_URI => null,
485+
ModuleConfig::OPTION_ORGANIZATION_URI => null,
486+
/**
487+
* @deprecated In Draft-43 of OIDFed specification, metadata claim 'homepage_uri' has been renamed to
488+
* 'organization_uri'. Use 'organization_uri' instead.
489+
*/
479490
ModuleConfig::OPTION_HOMEPAGE_URI => null,
480491
];

src/Controllers/Federation/EntityStatementController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,14 @@ public function configuration(): Response
8888
...(array_filter(
8989
[
9090
ClaimsEnum::OrganizationName->value => $this->moduleConfig->getOrganizationName(),
91+
ClaimsEnum::DisplayName->value => $this->moduleConfig->getDisplayName(),
92+
ClaimsEnum::Description->value => $this->moduleConfig->getDescription(),
93+
ClaimsEnum::Keywords->value => $this->moduleConfig->getKeywords(),
9194
ClaimsEnum::Contacts->value => $this->moduleConfig->getContacts(),
9295
ClaimsEnum::LogoUri->value => $this->moduleConfig->getLogoUri(),
9396
ClaimsEnum::PolicyUri->value => $this->moduleConfig->getPolicyUri(),
94-
ClaimsEnum::HomepageUri->value => $this->moduleConfig->getHomepageUri(),
97+
ClaimsEnum::InformationUri->value => $this->moduleConfig->getInformationUri(),
98+
ClaimsEnum::OrganizationUri->value => $this->moduleConfig->getOrganizationUri(),
9599
],
96100
)),
97101
ClaimsEnum::FederationFetchEndpoint->value => $this->routes->urlFederationFetch(),

src/ModuleConfig.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ class ModuleConfig
6666
final public const OPTION_FEDERATION_ENTITY_STATEMENT_DURATION = 'federation_entity_statement_duration';
6767
final public const OPTION_FEDERATION_AUTHORITY_HINTS = 'federation_authority_hints';
6868
final public const OPTION_ORGANIZATION_NAME = 'organization_name';
69+
final public const OPTION_DISPLAY_NAME = 'display_name';
70+
final public const OPTION_DESCRIPTION = 'description';
71+
final public const OPTION_KEYWORDS = 'keywords';
6972
final public const OPTION_CONTACTS = 'contacts';
7073
final public const OPTION_LOGO_URI = 'logo_uri';
7174
final public const OPTION_POLICY_URI = 'policy_uri';
75+
final public const OPTION_INFORMATION_URI = 'information_uri';
7276
final public const OPTION_HOMEPAGE_URI = 'homepage_uri';
77+
final public const OPTION_ORGANIZATION_URI = 'organization_uri';
7378
final public const OPTION_FEDERATION_ENABLED = 'federation_enabled';
7479
final public const OPTION_FEDERATION_CACHE_ADAPTER = 'federation_cache_adapter';
7580
final public const OPTION_FEDERATION_CACHE_ADAPTER_ARGUMENTS = 'federation_cache_adapter_arguments';
@@ -651,6 +656,42 @@ public function getOrganizationName(): ?string
651656
);
652657
}
653658

659+
public function getDisplayName(): ?string
660+
{
661+
return $this->config()->getOptionalString(
662+
self::OPTION_DISPLAY_NAME,
663+
null,
664+
);
665+
}
666+
667+
public function getDescription(): ?string
668+
{
669+
return $this->config()->getOptionalString(
670+
self::OPTION_DESCRIPTION,
671+
null,
672+
);
673+
}
674+
675+
/**
676+
* JSON array with one or more strings representing search keywords, tags, categories, or labels that
677+
* apply to this Entity.
678+
*
679+
* @return ?string[]
680+
*/
681+
public function getKeywords(): ?array
682+
{
683+
$keywords = $this->config()->getOptionalArray(
684+
self::OPTION_KEYWORDS,
685+
null,
686+
);
687+
688+
if (is_null($keywords)) {
689+
return null;
690+
}
691+
692+
return array_filter($keywords, fn($keyword) => is_string($keyword));
693+
}
694+
654695
public function getContacts(): ?array
655696
{
656697
return $this->config()->getOptionalArray(
@@ -675,6 +716,21 @@ public function getPolicyUri(): ?string
675716
);
676717
}
677718

719+
public function getInformationUri(): ?string
720+
{
721+
return $this->config()->getOptionalString(
722+
self::OPTION_INFORMATION_URI,
723+
null,
724+
);
725+
}
726+
727+
/**
728+
* @return string|null
729+
* TODO mivanci v7 Remove in next major release, as well as config constant.
730+
* In Draft-43 of OIDFed specification, metadata claim 'homepage_uri' has been renamed to
731+
* 'organization_uri'. Use 'organization_uri' instead.
732+
* @see self::getOrganizationUri()
733+
*/
678734
public function getHomepageUri(): ?string
679735
{
680736
return $this->config()->getOptionalString(
@@ -683,6 +739,14 @@ public function getHomepageUri(): ?string
683739
);
684740
}
685741

742+
public function getOrganizationUri(): ?string
743+
{
744+
return $this->config()->getOptionalString(
745+
self::OPTION_ORGANIZATION_URI,
746+
null,
747+
);
748+
}
749+
686750
public function getFederationCacheAdapterClass(): ?string
687751
{
688752
return $this->config()->getOptionalString(self::OPTION_FEDERATION_CACHE_ADAPTER, null);

tests/config/module_oidc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@
107107
ModuleConfig::OPTION_FEDERATION_TOKEN_SIGNER => Sha256::class,
108108

109109
ModuleConfig::OPTION_ORGANIZATION_NAME => 'Foo corp',
110+
ModuleConfig::OPTION_DISPLAY_NAME => 'Foo corp',
111+
ModuleConfig::OPTION_DESCRIPTION => 'Foo provider',
112+
ModuleConfig::OPTION_KEYWORDS => ['openid', 'oidc', 'op', 'federation'],
110113
ModuleConfig::OPTION_CONTACTS => [
111114
'John Doe [email protected]',
112115
],
113116
ModuleConfig::OPTION_LOGO_URI => 'https://example.org/logo',
114117
ModuleConfig::OPTION_POLICY_URI => 'https://example.org/policy',
118+
ModuleConfig::OPTION_INFORMATION_URI => 'https://example.org/info',
115119
ModuleConfig::OPTION_HOMEPAGE_URI => 'https://example.org',
120+
ModuleConfig::OPTION_ORGANIZATION_URI => 'https://example.org',
116121
];

tests/unit/src/ModuleConfigTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,33 @@ public function testCanGetCommonFederationOptions(): void
239239
$this->assertNotEmpty($this->sut()->getFederationAuthorityHints());
240240
$this->assertNotEmpty($this->sut()->getFederationTrustMarkTokens());
241241
$this->assertNotEmpty($this->sut()->getOrganizationName());
242+
$this->assertNotEmpty($this->sut()->getDisplayName());
243+
$this->assertNotEmpty($this->sut()->getDescription());
244+
$this->assertNotEmpty($this->sut()->getKeywords());
242245
$this->assertNotEmpty($this->sut()->getContacts());
243246
$this->assertNotEmpty($this->sut()->getLogoUri());
244247
$this->assertNotEmpty($this->sut()->getPolicyUri());
248+
$this->assertNotEmpty($this->sut()->getInformationUri());
245249
$this->assertNotEmpty($this->sut()->getHomepageUri());
250+
$this->assertNotEmpty($this->sut()->getOrganizationUri());
246251
$this->assertNotEmpty($this->sut()->getFederationCacheAdapterClass());
247252
$this->assertIsArray($this->sut()->getFederationCacheAdapterArguments());
248253
$this->assertNotEmpty($this->sut()->getFederationCacheMaxDurationForFetched());
249254
$this->assertNotEmpty($this->sut()->getFederationTrustAnchors());
250255
$this->assertNotEmpty($this->sut()->getFederationTrustAnchorIds());
251256
}
252257

258+
public function testKeywordsCanBeNull(): void
259+
{
260+
$this->assertNull(
261+
$this->sut(
262+
overrides: [
263+
ModuleConfig::OPTION_KEYWORDS => null,
264+
],
265+
)->getKeywords(),
266+
);
267+
}
268+
253269
public function testGetFederationTrustAnchorsThrowsOnEmptyIfFederationEnabled(): void
254270
{
255271
$this->expectException(ConfigurationError::class);

0 commit comments

Comments
 (0)