4
4
5
5
namespace SimpleSAML \Module \oidc \Controller \Federation ;
6
6
7
- use SimpleSAML \Module \oidc \Codebooks \ClaimNamesEnum ;
8
- use SimpleSAML \Module \oidc \Codebooks \ClaimValues \ClientRegistrationTypesEnum ;
9
- use SimpleSAML \Module \oidc \Codebooks \ClaimValues \TypeEnum ;
10
- use SimpleSAML \Module \oidc \Codebooks \EntityTypeEnum ;
11
- use SimpleSAML \Module \oidc \Codebooks \ErrorsEnum ;
12
- use SimpleSAML \Module \oidc \Codebooks \HttpHeadersEnum ;
13
- use SimpleSAML \Module \oidc \Codebooks \HttpHeaderValues \ContentTypeEnum ;
14
7
use SimpleSAML \Module \oidc \Codebooks \RoutesEnum ;
15
8
use SimpleSAML \Module \oidc \ModuleConfig ;
16
9
use SimpleSAML \Module \oidc \Repositories \ClientRepository ;
17
10
use SimpleSAML \Module \oidc \Services \JsonWebKeySetService ;
18
11
use SimpleSAML \Module \oidc \Services \JsonWebTokenBuilderService ;
19
12
use SimpleSAML \Module \oidc \Services \OpMetadataService ;
20
13
use SimpleSAML \Module \oidc \Utils \TimestampGenerator ;
14
+ use SimpleSAML \OpenID \Codebooks \ClaimsEnum ;
15
+ use SimpleSAML \OpenID \Codebooks \ClientRegistrationTypesEnum ;
16
+ use SimpleSAML \OpenID \Codebooks \ContentTypeEnum ;
17
+ use SimpleSAML \OpenID \Codebooks \EntityTypeEnum ;
18
+ use SimpleSAML \OpenID \Codebooks \ErrorsEnum ;
19
+ use SimpleSAML \OpenID \Codebooks \HttpHeadersEnum ;
20
+ use SimpleSAML \OpenID \Codebooks \JwtTypeEnum ;
21
+ use SimpleSAML \OpenID \Codebooks \RequestAuthenticationMethodsEnum ;
21
22
use Symfony \Component \HttpFoundation \JsonResponse ;
22
23
use Symfony \Component \HttpFoundation \Request ;
23
24
use Symfony \Component \HttpFoundation \Response ;
@@ -41,29 +42,29 @@ public function __construct(
41
42
public function configuration (): Response
42
43
{
43
44
$ builder = $ this ->jsonWebTokenBuilderService ->getFederationJwtBuilder ()
44
- ->withHeader (ClaimNamesEnum::Type ->value , TypeEnum ::EntityStatementJwt->value )
45
+ ->withHeader (ClaimsEnum::Typ ->value , JwtTypeEnum ::EntityStatementJwt->value )
45
46
->relatedTo ($ this ->moduleConfig ->getIssuer ()) // This is entity configuration (statement about itself).
46
47
->expiresAt (
47
48
(TimestampGenerator::utcImmutable ())->add ($ this ->moduleConfig ->getFederationEntityStatementDuration ()),
48
49
)->withClaim (
49
- ClaimNamesEnum::JsonWebKeySet ->value ,
50
+ ClaimsEnum::Jwks ->value ,
50
51
['keys ' => array_values ($ this ->jsonWebKeySetService ->federationKeys ()),],
51
52
)
52
53
->withClaim (
53
- ClaimNamesEnum ::Metadata->value ,
54
+ ClaimsEnum ::Metadata->value ,
54
55
[
55
56
EntityTypeEnum::FederationEntity->value => [
56
57
// Common https://openid.net/specs/openid-federation-1_0.html#name-common-metadata-parameters
57
58
...(array_filter (
58
59
[
59
- ClaimNamesEnum ::OrganizationName->value => $ this ->moduleConfig ->getOrganizationName (),
60
- ClaimNamesEnum ::Contacts->value => $ this ->moduleConfig ->getContacts (),
61
- ClaimNamesEnum ::LogoUri->value => $ this ->moduleConfig ->getLogoUri (),
62
- ClaimNamesEnum ::PolicyUri->value => $ this ->moduleConfig ->getPolicyUri (),
63
- ClaimNamesEnum ::HomepageUri->value => $ this ->moduleConfig ->getHomepageUri (),
60
+ ClaimsEnum ::OrganizationName->value => $ this ->moduleConfig ->getOrganizationName (),
61
+ ClaimsEnum ::Contacts->value => $ this ->moduleConfig ->getContacts (),
62
+ ClaimsEnum ::LogoUri->value => $ this ->moduleConfig ->getLogoUri (),
63
+ ClaimsEnum ::PolicyUri->value => $ this ->moduleConfig ->getPolicyUri (),
64
+ ClaimsEnum ::HomepageUri->value => $ this ->moduleConfig ->getHomepageUri (),
64
65
],
65
66
)),
66
- ClaimNamesEnum ::FederationFetchEndpoint->value =>
67
+ ClaimsEnum ::FederationFetchEndpoint->value =>
67
68
$ this ->moduleConfig ->getModuleUrl (RoutesEnum::OpenIdFederationFetch->value ),
68
69
// TODO mivanci Add when ready. Use ClaimsEnum for keys.
69
70
// https://openid.net/specs/openid-federation-1_0.html#name-federation-entity
@@ -78,12 +79,20 @@ public function configuration(): Response
78
79
//'jwks_uri',
79
80
//'jwks',
80
81
],
81
- // OP metadata with federation related claims.
82
+ // OP metadata with additional federation related claims.
82
83
EntityTypeEnum::OpenIdProvider->value => [
83
84
...$ this ->opMetadataService ->getMetadata (),
84
- ClaimNamesEnum ::ClientRegistrationTypesSupported->value => [
85
+ ClaimsEnum ::ClientRegistrationTypesSupported->value => [
85
86
ClientRegistrationTypesEnum::Automatic->value ,
86
87
],
88
+ ClaimsEnum::RequestAuthenticationMethodsSupported->value => [
89
+ ClaimsEnum::AuthorizationEndpoint->value => [
90
+ RequestAuthenticationMethodsEnum::RequestObject->value ,
91
+ ],
92
+ ],
93
+ ClaimsEnum::RequestAuthenticationSigningAlgValuesSupported->value => [
94
+ $ this ->moduleConfig ->getProtocolSigner ()->algorithmId (),
95
+ ],
87
96
],
88
97
],
89
98
);
@@ -92,7 +101,7 @@ public function configuration(): Response
92
101
is_array ($ authorityHints = $ this ->moduleConfig ->getFederationAuthorityHints ()) &&
93
102
(!empty ($ authorityHints ))
94
103
) {
95
- $ builder = $ builder ->withClaim (ClaimNamesEnum ::AuthorityHints->value , $ authorityHints );
104
+ $ builder = $ builder ->withClaim (ClaimsEnum ::AuthorityHints->value , $ authorityHints );
96
105
}
97
106
98
107
// Remaining claims, add if / when ready.
@@ -114,12 +123,12 @@ public function configuration(): Response
114
123
115
124
public function fetch (Request $ request ): Response
116
125
{
117
- $ issuer = $ request ->query ->get (ClaimNamesEnum::Issuer ->value );
126
+ $ issuer = $ request ->query ->get (ClaimsEnum::Iss ->value );
118
127
119
128
if (empty ($ issuer )) {
120
129
return $ this ->prepareJsonErrorResponse (
121
130
ErrorsEnum::InvalidRequest->value ,
122
- sprintf ('Missing parameter %s ' , ClaimNamesEnum::Issuer ->value ),
131
+ sprintf ('Missing parameter %s ' , ClaimsEnum::Iss ->value ),
123
132
400 ,
124
133
);
125
134
}
@@ -134,12 +143,12 @@ public function fetch(Request $request): Response
134
143
);
135
144
}
136
145
137
- $ subject = $ request ->query ->get (ClaimNamesEnum::Subject ->value );
146
+ $ subject = $ request ->query ->get (ClaimsEnum::Sub ->value );
138
147
139
148
if (empty ($ subject )) {
140
149
return $ this ->prepareJsonErrorResponse (
141
150
ErrorsEnum::InvalidRequest->value ,
142
- sprintf ('Missing parameter %s ' , ClaimNamesEnum::Subject ->value ),
151
+ sprintf ('Missing parameter %s ' , ClaimsEnum::Sub ->value ),
143
152
400 ,
144
153
);
145
154
}
@@ -165,28 +174,28 @@ public function fetch(Request $request): Response
165
174
}
166
175
167
176
$ builder = $ this ->jsonWebTokenBuilderService ->getFederationJwtBuilder ()
168
- ->withHeader (ClaimNamesEnum::Type ->value , TypeEnum ::EntityStatementJwt->value )
177
+ ->withHeader (ClaimsEnum::Typ ->value , JwtTypeEnum ::EntityStatementJwt->value )
169
178
->relatedTo ($ subject )
170
179
->expiresAt (
171
180
(TimestampGenerator::utcImmutable ())->add ($ this ->moduleConfig ->getFederationEntityStatementDuration ()),
172
181
)->withClaim (
173
- ClaimNamesEnum::JsonWebKeySet ->value ,
182
+ ClaimsEnum::Jwks ->value ,
174
183
$ jwks ,
175
184
)
176
185
->withClaim (
177
- ClaimNamesEnum ::Metadata->value ,
186
+ ClaimsEnum ::Metadata->value ,
178
187
[
179
188
EntityTypeEnum::OpenIdRelyingParty->value => [
180
- ClaimNamesEnum ::ClientName->value => $ client ->getName (),
181
- ClaimNamesEnum ::ClientId->value => $ client ->getIdentifier (),
182
- ClaimNamesEnum ::RedirectUris->value => $ client ->getRedirectUris (),
183
- ClaimNamesEnum ::Scope->value => implode (' ' , $ client ->getScopes ()),
184
- ClaimNamesEnum ::ClientRegistrationTypes->value => $ client ->getClientRegistrationTypes (),
189
+ ClaimsEnum ::ClientName->value => $ client ->getName (),
190
+ ClaimsEnum ::ClientId->value => $ client ->getIdentifier (),
191
+ ClaimsEnum ::RedirectUris->value => $ client ->getRedirectUris (),
192
+ ClaimsEnum ::Scope->value => implode (' ' , $ client ->getScopes ()),
193
+ ClaimsEnum ::ClientRegistrationTypes->value => $ client ->getClientRegistrationTypes (),
185
194
// Optional claims...
186
195
...(array_filter (
187
196
[
188
- ClaimNamesEnum ::BackChannelLogoutUri->value => $ client ->getBackChannelLogoutUri (),
189
- ClaimNamesEnum ::PostLogoutRedirectUris->value => $ client ->getPostLogoutRedirectUri (),
197
+ ClaimsEnum ::BackChannelLogoutUri->value => $ client ->getBackChannelLogoutUri (),
198
+ ClaimsEnum ::PostLogoutRedirectUris->value => $ client ->getPostLogoutRedirectUri (),
190
199
],
191
200
)),
192
201
// TODO mivanci Continue
0 commit comments