11from authlib .oauth2 .rfc8414 import AuthorizationServerMetadata
2+ from authlib .oauth2 .rfc8414 .models import validate_array_value
23
34
45class OpenIDProviderMetadata (AuthorizationServerMetadata ):
@@ -53,7 +54,7 @@ def validate_acr_values_supported(self):
5354 """OPTIONAL. JSON array containing a list of the Authentication
5455 Context Class References that this OP supports.
5556 """
56- _validate_array_value (self , 'acr_values_supported' )
57+ validate_array_value (self , 'acr_values_supported' )
5758
5859 def validate_subject_types_supported (self ):
5960 """REQUIRED. JSON array containing a list of the Subject Identifier
@@ -102,35 +103,35 @@ def validate_id_token_encryption_alg_values_supported(self):
102103 algorithms (alg values) supported by the OP for the ID Token to
103104 encode the Claims in a JWT.
104105 """
105- _validate_array_value (self , 'id_token_encryption_alg_values_supported' )
106+ validate_array_value (self , 'id_token_encryption_alg_values_supported' )
106107
107108 def validate_id_token_encryption_enc_values_supported (self ):
108109 """OPTIONAL. JSON array containing a list of the JWE encryption
109110 algorithms (enc values) supported by the OP for the ID Token to
110111 encode the Claims in a JWT.
111112 """
112- _validate_array_value (self , 'id_token_encryption_enc_values_supported' )
113+ validate_array_value (self , 'id_token_encryption_enc_values_supported' )
113114
114115 def validate_userinfo_signing_alg_values_supported (self ):
115116 """OPTIONAL. JSON array containing a list of the JWS signing
116117 algorithms (alg values) [JWA] supported by the UserInfo Endpoint
117118 to encode the Claims in a JWT. The value none MAY be included.
118119 """
119- _validate_array_value (self , 'userinfo_signing_alg_values_supported' )
120+ validate_array_value (self , 'userinfo_signing_alg_values_supported' )
120121
121122 def validate_userinfo_encryption_alg_values_supported (self ):
122123 """OPTIONAL. JSON array containing a list of the JWE encryption
123124 algorithms (alg values) [JWA] supported by the UserInfo Endpoint
124125 to encode the Claims in a JWT.
125126 """
126- _validate_array_value (self , 'userinfo_encryption_alg_values_supported' )
127+ validate_array_value (self , 'userinfo_encryption_alg_values_supported' )
127128
128129 def validate_userinfo_encryption_enc_values_supported (self ):
129130 """OPTIONAL. JSON array containing a list of the JWE encryption
130131 algorithms (enc values) [JWA] supported by the UserInfo Endpoint
131132 to encode the Claims in a JWT.
132133 """
133- _validate_array_value (self , 'userinfo_encryption_enc_values_supported' )
134+ validate_array_value (self , 'userinfo_encryption_enc_values_supported' )
134135
135136 def validate_request_object_signing_alg_values_supported (self ):
136137 """OPTIONAL. JSON array containing a list of the JWS signing
@@ -160,15 +161,15 @@ def validate_request_object_encryption_alg_values_supported(self):
160161 These algorithms are used both when the Request Object is passed
161162 by value and when it is passed by reference.
162163 """
163- _validate_array_value (self , 'request_object_encryption_alg_values_supported' )
164+ validate_array_value (self , 'request_object_encryption_alg_values_supported' )
164165
165166 def validate_request_object_encryption_enc_values_supported (self ):
166167 """OPTIONAL. JSON array containing a list of the JWE encryption
167168 algorithms (enc values) supported by the OP for Request Objects.
168169 These algorithms are used both when the Request Object is passed
169170 by value and when it is passed by reference.
170171 """
171- _validate_array_value (self , 'request_object_encryption_enc_values_supported' )
172+ validate_array_value (self , 'request_object_encryption_enc_values_supported' )
172173
173174 def validate_display_values_supported (self ):
174175 """OPTIONAL. JSON array containing a list of the display parameter
@@ -195,8 +196,6 @@ def validate_claim_types_supported(self):
195196 """
196197 values = self .get ('claim_types_supported' )
197198 if not values :
198- # If omitted, the implementation supports only normal Claims
199- self ['claim_types_supported' ] = ['normal' ]
200199 return
201200
202201 if not isinstance (values , list ):
@@ -212,15 +211,15 @@ def validate_claims_supported(self):
212211 for. Note that for privacy or other reasons, this might not be an
213212 exhaustive list.
214213 """
215- _validate_array_value (self , 'claims_supported' )
214+ validate_array_value (self , 'claims_supported' )
216215
217216 def validate_claims_locales_supported (self ):
218217 """OPTIONAL. Languages and scripts supported for values in Claims
219218 being returned, represented as a JSON array of BCP47 [RFC5646]
220219 language tag values. Not all languages and scripts are necessarily
221220 supported for all Claim values.
222221 """
223- _validate_array_value (self , 'claims_locales_supported' )
222+ validate_array_value (self , 'claims_locales_supported' )
224223
225224 def validate_claims_parameter_supported (self ):
226225 """OPTIONAL. Boolean value specifying whether the OP supports use of
@@ -251,6 +250,11 @@ def validate_require_request_uri_registration(self):
251250 """
252251 _validate_boolean_value (self , 'require_request_uri_registration' )
253252
253+ @property
254+ def claim_types_supported (self ):
255+ # If omitted, the implementation supports only normal Claims
256+ return self .get ('claim_types_supported' , ['normal' ])
257+
254258 @property
255259 def claims_parameter_supported (self ):
256260 # If omitted, the default value is false.
@@ -271,14 +275,9 @@ def require_request_uri_registration(self):
271275 # If omitted, the default value is false.
272276 return self .get ('require_request_uri_registration' , False )
273277
278+
274279def _validate_boolean_value (metadata , key ):
275280 if key not in metadata :
276281 return
277282 if metadata [key ] not in (True , False ):
278283 raise ValueError ('"{}" MUST be boolean' .format (key ))
279-
280-
281- def _validate_array_value (metadata , key ):
282- values = metadata .get (key )
283- if values is not None and not isinstance (values , list ):
284- raise ValueError ('"{}" MUST be JSON array' .format (key ))
0 commit comments