Skip to content

Commit 91c5756

Browse files
authored
Enable TrustMarks listing in Entity Configuration (#263)
* Update to OpenIDFed draft 40 * Enable TrustMarks listing in entity configuration --------- Co-authored-by: Marko Ivančić <[email protected]>
1 parent 7bfbe5b commit 91c5756

File tree

7 files changed

+98
-48
lines changed

7 files changed

+98
-48
lines changed

config-templates/module_oidc.php

+6
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@
355355
//'https://intermediate.example.org/',
356356
],
357357

358+
// (optional) Federation Trust Mark tokens. An array of tokens (signed JWTs), each representing a Trust Mark
359+
// issued to this entity.
360+
ModuleConfig::OPTION_FEDERATION_TRUST_MARK_TOKENS => [
361+
// 'eyJ...GHg',
362+
],
363+
358364
// (optional) Dedicated federation cache adapter, used to cache federation artifacts like trust chains, entity
359365
// statements, etc. It will also be used for token reuse check in federation context. Setting this option is
360366
// recommended in production environments. If set to null, no caching will be used. Can be set to any

src/Controller/Federation/EntityStatementController.php

+30-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use SimpleSAML\OpenID\Codebooks\ErrorsEnum;
2121
use SimpleSAML\OpenID\Codebooks\HttpHeadersEnum;
2222
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum;
23-
use SimpleSAML\OpenID\Codebooks\RequestAuthenticationMethodsEnum;
23+
use SimpleSAML\OpenID\Federation;
2424
use Symfony\Component\HttpFoundation\JsonResponse;
2525
use Symfony\Component\HttpFoundation\Request;
2626
use Symfony\Component\HttpFoundation\Response;
@@ -40,6 +40,7 @@ public function __construct(
4040
private readonly OpMetadataService $opMetadataService,
4141
private readonly ClientRepository $clientRepository,
4242
private readonly Helpers $helpers,
43+
private readonly Federation $federation,
4344
private readonly ?FederationCache $federationCache,
4445
) {
4546
if (!$this->moduleConfig->getFederationEnabled()) {
@@ -53,6 +54,8 @@ public function __construct(
5354
* @return \Symfony\Component\HttpFoundation\Response
5455
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
5556
* @throws \ReflectionException
57+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
58+
* @throws \Psr\SimpleCache\InvalidArgumentException
5659
*/
5760
public function configuration(): Response
5861
{
@@ -99,6 +102,7 @@ public function configuration(): Response
99102
//'federation_trust_mark_list_endpoint',
100103
//'federation_trust_mark_endpoint',
101104
//'federation_historical_keys_endpoint',
105+
//'endpoint_auth_signing_alg_values_supported'
102106
// Common https://openid.net/specs/openid-federation-1_0.html#name-common-metadata-parameters
103107
//'signed_jwks_uri',
104108
//'jwks_uri',
@@ -110,14 +114,6 @@ public function configuration(): Response
110114
ClaimsEnum::ClientRegistrationTypesSupported->value => [
111115
ClientRegistrationTypesEnum::Automatic->value,
112116
],
113-
ClaimsEnum::RequestAuthenticationMethodsSupported->value => [
114-
ClaimsEnum::AuthorizationEndpoint->value => [
115-
RequestAuthenticationMethodsEnum::RequestObject->value,
116-
],
117-
],
118-
ClaimsEnum::RequestAuthenticationSigningAlgValuesSupported->value => [
119-
$this->moduleConfig->getProtocolSigner()->algorithmId(),
120-
],
121117
],
122118
],
123119
);
@@ -129,14 +125,32 @@ public function configuration(): Response
129125
$builder = $builder->withClaim(ClaimsEnum::AuthorityHints->value, $authorityHints);
130126
}
131127

128+
if (
129+
is_array($trustMarkTokens = $this->moduleConfig->getFederationTrustMarkTokens()) &&
130+
(!empty($trustMarkTokens))
131+
) {
132+
$trustMarks = array_map(function (string $token): array {
133+
$trustMarkEntity = $this->federation->trustMarkFactory()->fromToken($token);
134+
135+
if ($trustMarkEntity->getSubject() !== $this->moduleConfig->getIssuer()) {
136+
throw OidcServerException::serverError(sprintf(
137+
'Trust Mark %s is not intended for this entity.',
138+
$trustMarkEntity->getIdentifier(),
139+
));
140+
}
141+
142+
return [
143+
ClaimsEnum::Id->value => $trustMarkEntity->getIdentifier(),
144+
ClaimsEnum::TrustMark->value => $token,
145+
];
146+
}, $trustMarkTokens);
147+
148+
$builder = $builder->withClaim(ClaimsEnum::TrustMarks->value, $trustMarks);
149+
}
150+
151+
// TODO mivanci Continue
132152
// Remaining claims, add if / when ready.
133153
// * crit
134-
// * trust_marks
135-
// * trust_mark_issuers
136-
// * source_endpoint
137-
138-
// Note: claims which should only be present in Trust Anchors
139-
// * trust_mark_owners
140154

141155
$jws = $this->jsonWebTokenBuilderService->getSignedFederationJwt($builder);
142156

@@ -227,6 +241,7 @@ public function fetch(Request $request): Response
227241
],
228242
);
229243

244+
// TODO mivanci Continue
230245
// Note: claims which can be present in subordinate statements:
231246
// * metadata_policy
232247
// * constraints

0 commit comments

Comments
 (0)