20
20
use SimpleSAML \OpenID \Codebooks \ErrorsEnum ;
21
21
use SimpleSAML \OpenID \Codebooks \HttpHeadersEnum ;
22
22
use SimpleSAML \OpenID \Codebooks \JwtTypesEnum ;
23
- use SimpleSAML \OpenID \Codebooks \ RequestAuthenticationMethodsEnum ;
23
+ use SimpleSAML \OpenID \Federation ;
24
24
use Symfony \Component \HttpFoundation \JsonResponse ;
25
25
use Symfony \Component \HttpFoundation \Request ;
26
26
use Symfony \Component \HttpFoundation \Response ;
@@ -40,6 +40,7 @@ public function __construct(
40
40
private readonly OpMetadataService $ opMetadataService ,
41
41
private readonly ClientRepository $ clientRepository ,
42
42
private readonly Helpers $ helpers ,
43
+ private readonly Federation $ federation ,
43
44
private readonly ?FederationCache $ federationCache ,
44
45
) {
45
46
if (!$ this ->moduleConfig ->getFederationEnabled ()) {
@@ -53,6 +54,8 @@ public function __construct(
53
54
* @return \Symfony\Component\HttpFoundation\Response
54
55
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
55
56
* @throws \ReflectionException
57
+ * @throws \SimpleSAML\OpenID\Exceptions\JwsException
58
+ * @throws \Psr\SimpleCache\InvalidArgumentException
56
59
*/
57
60
public function configuration (): Response
58
61
{
@@ -99,6 +102,7 @@ public function configuration(): Response
99
102
//'federation_trust_mark_list_endpoint',
100
103
//'federation_trust_mark_endpoint',
101
104
//'federation_historical_keys_endpoint',
105
+ //'endpoint_auth_signing_alg_values_supported'
102
106
// Common https://openid.net/specs/openid-federation-1_0.html#name-common-metadata-parameters
103
107
//'signed_jwks_uri',
104
108
//'jwks_uri',
@@ -110,14 +114,6 @@ public function configuration(): Response
110
114
ClaimsEnum::ClientRegistrationTypesSupported->value => [
111
115
ClientRegistrationTypesEnum::Automatic->value ,
112
116
],
113
- ClaimsEnum::RequestAuthenticationMethodsSupported->value => [
114
- ClaimsEnum::AuthorizationEndpoint->value => [
115
- RequestAuthenticationMethodsEnum::RequestObject->value ,
116
- ],
117
- ],
118
- ClaimsEnum::RequestAuthenticationSigningAlgValuesSupported->value => [
119
- $ this ->moduleConfig ->getProtocolSigner ()->algorithmId (),
120
- ],
121
117
],
122
118
],
123
119
);
@@ -129,14 +125,32 @@ public function configuration(): Response
129
125
$ builder = $ builder ->withClaim (ClaimsEnum::AuthorityHints->value , $ authorityHints );
130
126
}
131
127
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
132
152
// Remaining claims, add if / when ready.
133
153
// * 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
140
154
141
155
$ jws = $ this ->jsonWebTokenBuilderService ->getSignedFederationJwt ($ builder );
142
156
@@ -227,6 +241,7 @@ public function fetch(Request $request): Response
227
241
],
228
242
);
229
243
244
+ // TODO mivanci Continue
230
245
// Note: claims which can be present in subordinate statements:
231
246
// * metadata_policy
232
247
// * constraints
0 commit comments