Skip to content

Commit e0aa1cf

Browse files
authored
Bump to OpenID Federation draft 43 (#9)
* Rename trust_mark_id to trust_mark_type * Update claim names * Update note about supported draft version
1 parent 356626c commit e0aa1cf

26 files changed

Lines changed: 239 additions & 235 deletions

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Library can be installed by using Composer:
1515
composer require simplesamlphp/openid
1616
```
1717

18-
## OpenID Federation (draft 42)
18+
## OpenID Federation (draft 43)
1919

2020
The initial functionality of the library revolves around the OpenID Federation specification. To use it, create an
2121
instance of the class `\SimpleSAML\OpenID\Federation`
@@ -207,8 +207,8 @@ Federation tools expose Trust Mark Fetcher which you can use to dynamically fetc
207207

208208
/** @var \SimpleSAML\OpenID\Federation $federationTools */
209209

210-
// Trust Mark ID that you want to fetch.
211-
$trustMarkId = 'https://example.com/trust-mark/member';
210+
// Trust Mark Type that you want to fetch.
211+
$trustMarkType = 'https://example.com/trust-mark/member';
212212
// ID of Subject for which to fetch the Trust Mark.
213213
$subjectId = 'https://leaf-entity.org'
214214
// ID of the Trust Mark Issuer from which to fetch the Trust Mark.
@@ -222,7 +222,7 @@ try {
222222

223223
// Fetch the Trust Mark from Issuer.
224224
$trustMarkEntity = $federationTools->trustMarkFetcher()->fromCacheOrFederationTrustMarkEndpoint(
225-
$trustMarkId,
225+
$trustMarkType,
226226
$subjectId,
227227
$trustMarkIssuerConfigurationStatement
228228
);
@@ -237,7 +237,7 @@ try {
237237
### Validating Trust Marks
238238

239239
Federation tools expose Trust Mark Validator with several methods for validating Trust Marks, with the most common
240-
one being the one to validate Trust Mark for some entity simply based on the Trust Mark ID.
240+
one being the one to validate Trust Mark for some entity simply based on the Trust Mark Type.
241241

242242
If cache is utilized, Trust Mark validation will be cached with cache TTL being the minimum expiration
243243
time of Trust Mark, Leaf Entity Statement or `maxCacheDuration`, whatever is smaller.
@@ -249,25 +249,25 @@ time of Trust Mark, Leaf Entity Statement or `maxCacheDuration`, whatever is sma
249249
/** @var \SimpleSAML\OpenID\Federation\TrustChain $trustChain */
250250

251251

252-
// Trust Mark ID that you want to validate.
253-
$trustMarkId = 'https://example.com/trust-mark/member';
252+
// Trust Mark Type that you want to validate.
253+
$trustMarkType = 'https://example.com/trust-mark/member';
254254
// Leaf for which you want to validate the Trust Mark with ID above.
255255
$leafEntityConfigurationStatement = $trustChain->getResolvedLeaf();
256256
// Trust Anchor under which you want to validate Trust Mark.
257257
$trustAnchorConfigurationStatement = $trustChain->getResolvedTrustAnchor();
258258

259259
try {
260260
// Example which queries cache for previously validated Trust Mark, and does formal validation if not cached.
261-
$federationTools->trustMarkValidator()->fromCacheOrDoForTrustMarkId(
262-
$trustMarkId,
261+
$federationTools->trustMarkValidator()->fromCacheOrDoForTrustMarkType(
262+
$trustMarkType,
263263
$leafEntityConfigurationStatement,
264264
$trustAnchorConfigurationStatement,
265265
$expectedJwtType = \SimpleSAML\OpenID\Codebooks\JwtTypesEnum::TrustMarkJwt,
266266
);
267267

268268
// Example which always does formal validation (does not use cache).
269-
$federationTools->trustMarkValidator()->doForTrustMarkId(
270-
$trustMarkId,
269+
$federationTools->trustMarkValidator()->doForTrustMarkType(
270+
$trustMarkType,
271271
$leafEntityConfigurationStatement,
272272
$trustAnchorConfigurationStatement,
273273
$expectedJwtType = \SimpleSAML\OpenID\Codebooks\JwtTypesEnum::TrustMarkJwt,

src/Codebooks/ClaimsEnum.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum ClaimsEnum: string
4747
case Delegation = 'delegation';
4848
case Description = 'description';
4949
case Display = 'display';
50+
case DisplayName = 'display_name';
5051
case EndSessionEndpoint = 'end_session_endpoint';
5152
// ExpirationTime
5253
case Exp = 'exp';
@@ -65,6 +66,7 @@ enum ClaimsEnum: string
6566
// Identifier
6667
case Id = 'id';
6768
case IdTokenSigningAlgValuesSupported = 'id_token_signing_alg_values_supported';
69+
case InformationUri = 'information_uri';
6870
case IntrospectionEndpoint = 'introspection_endpoint';
6971
case IntrospectionEndpointAuthMethodsSupported = 'introspection_endpoint_auth_methods_supported';
7072
case IntrospectionEndpointAuthSigningAlgValuesSupported =
@@ -77,6 +79,7 @@ enum ClaimsEnum: string
7779
// JsonWebKeySet
7880
case Jwks = 'jwks';
7981
case JwksUri = 'jwks_uri';
82+
case Keywords = 'keywords';
8083
// KeyId
8184
case Kid = 'kid';
8285
case KeyAttestationsRequired = 'key_attestations_required';
@@ -98,6 +101,7 @@ enum ClaimsEnum: string
98101
// OpenIDProviderTermsOfServiceUri
99102
case OpTosUri = 'op_tos_uri';
100103
case OrganizationName = 'organization_name';
104+
case OrganizationUri = 'organization_uri';
101105
case Path = 'path';
102106
case PolicyUri = 'policy_uri';
103107
case PostLogoutRedirectUris = 'post_logout_redirect_uris';
@@ -139,8 +143,8 @@ enum ClaimsEnum: string
139143
case Type = 'type';
140144
case TrustChain = 'trust_chain';
141145
case TrustMark = 'trust_mark';
142-
case TrustMarkId = 'trust_mark_id';
143146
case TrustMarkOwners = 'trust_mark_owners';
147+
case TrustMarkType = 'trust_mark_type';
144148
case TrustMarks = 'trust_marks';
145149
// UserInterfaceLocalesSupported
146150
case UiLocalesSupported = 'ui_locales_supported';

src/Codebooks/ParamsEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ enum ParamsEnum: string
3535
case Scope = 'scope';
3636
case State = 'state';
3737
case TrustMarked = 'trust_marked';
38-
case TrustMarkId = 'trust_mark_id';
38+
case TrustMarkType = 'trust_mark_type';
3939
case UiLocales = 'ui_locales';
4040
}

src/Federation/Claims/TrustMarkOwnersClaimBag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ public function __construct(TrustMarkOwnersClaimValue ...$trustMarkOwnersClaimVa
1919
public function add(TrustMarkOwnersClaimValue ...$trustMarkOwnersClaimValues): void
2020
{
2121
foreach ($trustMarkOwnersClaimValues as $trustMarkOwnersClaimValue) {
22-
$this->trustMarkOwnersClaimValues[$trustMarkOwnersClaimValue->getTrustMarkId()] =
22+
$this->trustMarkOwnersClaimValues[$trustMarkOwnersClaimValue->getTrustMarkType()] =
2323
$trustMarkOwnersClaimValue;
2424
}
2525
}
2626

27-
public function has(string $trustMarkId): bool
27+
public function has(string $trustMarkType): bool
2828
{
29-
return isset($this->trustMarkOwnersClaimValues[$trustMarkId]);
29+
return isset($this->trustMarkOwnersClaimValues[$trustMarkType]);
3030
}
3131

32-
public function get(string $trustMarkId): ?TrustMarkOwnersClaimValue
32+
public function get(string $trustMarkType): ?TrustMarkOwnersClaimValue
3333
{
34-
return $this->trustMarkOwnersClaimValues[$trustMarkId] ?? null;
34+
return $this->trustMarkOwnersClaimValues[$trustMarkType] ?? null;
3535
}
3636

3737
/**

src/Federation/Claims/TrustMarkOwnersClaimValue.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
class TrustMarkOwnersClaimValue implements JsonSerializable
1212
{
1313
/**
14-
* @param non-empty-string $trustMarkId
14+
* @param non-empty-string $trustMarkType
1515
* @param non-empty-string $subject
1616
* @param array<non-empty-string,mixed> $otherClaims
1717
*/
1818
public function __construct(
19-
protected readonly string $trustMarkId,
19+
protected readonly string $trustMarkType,
2020
protected readonly string $subject,
2121
protected readonly JwksClaim $jwks,
2222
protected readonly array $otherClaims = [],
@@ -26,9 +26,9 @@ public function __construct(
2626
/**
2727
* @return non-empty-string
2828
*/
29-
public function getTrustMarkId(): string
29+
public function getTrustMarkType(): string
3030
{
31-
return $this->trustMarkId;
31+
return $this->trustMarkType;
3232
}
3333

3434
/**
@@ -59,7 +59,7 @@ public function jsonSerialize(): array
5959
{
6060
return array_merge(
6161
[
62-
ClaimsEnum::TrustMarkId->value => $this->trustMarkId,
62+
ClaimsEnum::TrustMarkType->value => $this->trustMarkType,
6363
ClaimsEnum::Sub->value => $this->subject,
6464
ClaimsEnum::Jwks->value => $this->jwks->getValue(),
6565
],

src/Federation/Claims/TrustMarksClaimBag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ public function getAll(): array
3232
}
3333

3434
/**
35-
* @param non-empty-string $trustMarkId
35+
* @param non-empty-string $trustMarkType
3636
* @return \SimpleSAML\OpenID\Federation\Claims\TrustMarksClaimValue[]
3737
*/
38-
public function getAllFor(string $trustMarkId): array
38+
public function getAllFor(string $trustMarkType): array
3939
{
4040
return array_values(array_filter(
4141
$this->trustMarksClaimValues,
42-
fn(TrustMarksClaimValue $trustMarkClaim): bool => $trustMarkClaim->getTrustMarkId() === $trustMarkId,
42+
fn(TrustMarksClaimValue $trustMarkClaim): bool => $trustMarkClaim->getTrustMarkType() === $trustMarkType,
4343
));
4444
}
4545

46-
public function getFirstFor(string $trustMarkId): ?TrustMarksClaimValue
46+
public function getFirstFor(string $trustMarkType): ?TrustMarksClaimValue
4747
{
4848
foreach ($this->trustMarksClaimValues as $trustMarkClaim) {
49-
if ($trustMarkClaim->getTrustMarkId() === $trustMarkId) {
49+
if ($trustMarkClaim->getTrustMarkType() === $trustMarkType) {
5050
return $trustMarkClaim;
5151
}
5252
}

src/Federation/Claims/TrustMarksClaimValue.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
class TrustMarksClaimValue implements JsonSerializable
1515
{
1616
/**
17-
* @param non-empty-string $trustMarkId
17+
* @param non-empty-string $trustMarkType
1818
* @param non-empty-string $trustMark
1919
* @param array<non-empty-string,mixed> $otherClaims
2020
*/
2121
public function __construct(
22-
protected readonly string $trustMarkId,
22+
protected readonly string $trustMarkType,
2323
protected readonly string $trustMark,
2424
protected readonly array $otherClaims = [],
2525
) {
@@ -28,9 +28,9 @@ public function __construct(
2828
/**
2929
* @return non-empty-string
3030
*/
31-
public function getTrustMarkId(): string
31+
public function getTrustMarkType(): string
3232
{
33-
return $this->trustMarkId;
33+
return $this->trustMarkType;
3434
}
3535

3636
/**
@@ -56,7 +56,7 @@ public function jsonSerialize(): array
5656
{
5757
return array_merge(
5858
[
59-
ClaimsEnum::TrustMarkId->value => $this->trustMarkId,
59+
ClaimsEnum::TrustMarkType->value => $this->trustMarkType,
6060
ClaimsEnum::TrustMark->value => $this->trustMark,
6161
],
6262
$this->otherClaims,

src/Federation/EntityStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ public function getTrustMarks(): ?TrustMarksClaimBag
210210
public function getTrustMarkOwners(): ?TrustMarkOwnersClaimBag
211211
{
212212
// trust_mark_owners
213-
// OPTIONAL. It is a JSON object with member names that are Trust Mark identifiers and each
214-
// corresponding value being a JSON object with members: sub, jwks and optionally other members.
213+
// OPTIONAL. It is a JSON object with member names that are Trust Mark Type identifiers, and each
214+
// corresponding value is a JSON object with members: sub, jwks and optionally other members.
215215

216216
$claimKey = ClaimsEnum::TrustMarkOwners->value;
217217
$trustMarkOwnersClaimData = $this->getPayloadClaim($claimKey);

src/Federation/Factories/FederationClaimFactory.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public function __construct(
2626
* @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException
2727
*/
2828
public function buildTrustMarksClaimValue(
29-
mixed $trustMarkId,
29+
mixed $trustMarkType,
3030
mixed $trustMark,
3131
mixed $otherClaims = [],
3232
): TrustMarksClaimValue {
33-
$trustMarkId = $this->helpers->type()->ensureNonEmptyString($trustMarkId);
33+
$trustMarkType = $this->helpers->type()->ensureNonEmptyString($trustMarkType);
3434
$trustMark = $this->helpers->type()->ensureNonEmptyString($trustMark);
3535
$otherClaims = $this->helpers->type()->ensureArrayWithKeysAsNonEmptyStrings($otherClaims);
3636

37-
return new TrustMarksClaimValue($trustMarkId, $trustMark, $otherClaims);
37+
return new TrustMarksClaimValue($trustMarkType, $trustMark, $otherClaims);
3838
}
3939

4040
/**
@@ -47,12 +47,12 @@ public function buildTrustMarksClaimValueFrom(mixed $trustMarksClaimData): Trust
4747
$trustMarksClaimData = $this->helpers->type()->ensureArray($trustMarksClaimData);
4848

4949
// Each JSON object MUST contain the following two claims and MAY contain other claims.
50-
// trust_mark_id
51-
// The Trust Mark identifier. It MUST be the same value as the id claim contained in the Trust Mark JWT.
50+
// trust_mark_type
51+
// The Trust Mark Type identifier. It MUST be the same value as the id claim contained in the Trust Mark JWT.
5252
// trust_mark
5353
// A signed JSON Web Token that represents a Trust Mark.
54-
$trustMarkId = $trustMarksClaimData[ClaimsEnum::TrustMarkId->value] ?? throw new TrustMarkException(
55-
'No ID present in Trust Mark claim.',
54+
$trustMarkType = $trustMarksClaimData[ClaimsEnum::TrustMarkType->value] ?? throw new TrustMarkException(
55+
'No type present in Trust Mark claim.',
5656
);
5757

5858
$trustMark = $trustMarksClaimData[ClaimsEnum::TrustMark->value] ?? throw new TrustMarkException(
@@ -61,11 +61,11 @@ public function buildTrustMarksClaimValueFrom(mixed $trustMarksClaimData): Trust
6161

6262
$otherClaims = array_diff_key(
6363
$trustMarksClaimData,
64-
[ClaimsEnum::TrustMarkId->value => true, ClaimsEnum::TrustMark->value => true],
64+
[ClaimsEnum::TrustMarkType->value => true, ClaimsEnum::TrustMark->value => true],
6565
);
6666

6767
return $this->buildTrustMarksClaimValue(
68-
$trustMarkId,
68+
$trustMarkType,
6969
$trustMark,
7070
$otherClaims,
7171
);
@@ -77,18 +77,18 @@ public function buildTrustMarksClaimBag(TrustMarksClaimValue ...$trustMarksClaim
7777
}
7878

7979
public function buildTrustMarkOwnersClaimValue(
80-
mixed $trustMarkId,
80+
mixed $trustMarkType,
8181
mixed $subject,
8282
mixed $jwks,
8383
mixed $otherClaims = [],
8484
): TrustMarkOwnersClaimValue {
85-
$trustMarkId = $this->helpers->type()->ensureNonEmptyString($trustMarkId);
85+
$trustMarkType = $this->helpers->type()->ensureNonEmptyString($trustMarkType);
8686
$subject = $this->helpers->type()->ensureNonEmptyString($subject);
8787
$jwksClaim = $this->claimFactory->buildJwks($jwks);
8888
$otherClaims = $this->helpers->type()->ensureArrayWithKeysAsNonEmptyStrings($otherClaims);
8989

9090
return new TrustMarkOwnersClaimValue(
91-
$trustMarkId,
91+
$trustMarkType,
9292
$subject,
9393
$jwksClaim,
9494
$otherClaims,
@@ -105,7 +105,7 @@ public function buildTrustMarkOwnersClaimBagFrom(mixed $trustMarkOwnersClaimData
105105

106106
$trustMarkOwnersClaimValues = [];
107107

108-
// It is a JSON object with member names that are Trust Mark identifiers and each corresponding value
108+
// It is a JSON object with member names that are Trust Mark Type identifiers and each corresponding value
109109
// being a JSON object with these members:
110110
// sub
111111
// REQUIRED Identifier of the Trust Mark Owner.
@@ -114,7 +114,7 @@ public function buildTrustMarkOwnersClaimBagFrom(mixed $trustMarkOwnersClaimData
114114
// for signing.
115115
// Other members MAY also be defined and used.
116116

117-
foreach ($trustMarkOwnersClaimData as $trustMarkId => $trustMarkOwnersClaim) {
117+
foreach ($trustMarkOwnersClaimData as $trustMarkType => $trustMarkOwnersClaim) {
118118
$trustMarkOwnersClaim = $this->helpers->type()->ensureArray($trustMarkOwnersClaim);
119119

120120

@@ -127,11 +127,11 @@ public function buildTrustMarkOwnersClaimBagFrom(mixed $trustMarkOwnersClaimData
127127

128128
$otherClaims = array_diff_key(
129129
$trustMarkOwnersClaim,
130-
[ClaimsEnum::TrustMarkId->value => true, ClaimsEnum::TrustMark->value => true],
130+
[ClaimsEnum::TrustMarkType->value => true, ClaimsEnum::TrustMark->value => true],
131131
);
132132

133133
$trustMarkOwnersClaimValues[] = $this->buildTrustMarkOwnersClaimValue(
134-
$trustMarkId,
134+
$trustMarkType,
135135
$subject,
136136
$jwks,
137137
$otherClaims,

src/Federation/TrustMark.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ public function getSubject(): string
6363
* @return non-empty-string
6464
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
6565
*/
66-
public function getTrustMarkId(): string
66+
public function getTrustMarkType(): string
6767
{
68-
$claimKey = ClaimsEnum::TrustMarkId->value;
68+
$claimKey = ClaimsEnum::TrustMarkType->value;
6969

70-
$trustMarkId = $this->getPayloadClaim($claimKey) ?? throw new TrustMarkException(
71-
'No Trust Mark ID claim found.',
70+
$trustMarkType = $this->getPayloadClaim($claimKey) ?? throw new TrustMarkException(
71+
'No Trust Mark Type claim found.',
7272
);
7373

74-
return $this->helpers->type()->ensureNonEmptyString($trustMarkId);
74+
return $this->helpers->type()->ensureNonEmptyString($trustMarkType);
7575
}
7676

7777
/**
@@ -164,7 +164,7 @@ protected function validate(): void
164164
$this->validateByCallbacks(
165165
$this->getIssuer(...),
166166
$this->getSubject(...),
167-
$this->getTrustMarkId(...),
167+
$this->getTrustMarkType(...),
168168
$this->getIssuedAt(...),
169169
$this->getLogoUri(...),
170170
$this->getExpirationTime(...),

0 commit comments

Comments
 (0)