2020use SimpleSAML \OpenID \Codebooks \ErrorsEnum ;
2121use SimpleSAML \OpenID \Codebooks \HttpHeadersEnum ;
2222use SimpleSAML \OpenID \Codebooks \JwtTypesEnum ;
23- use SimpleSAML \OpenID \Codebooks \ RequestAuthenticationMethodsEnum ;
23+ use SimpleSAML \OpenID \Federation ;
2424use Symfony \Component \HttpFoundation \JsonResponse ;
2525use Symfony \Component \HttpFoundation \Request ;
2626use 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