77from typing import List
88from typing import Optional
99
10+ from idpyoidc .client .defaults import OAUTH2_SERVER_METADATA_URL
1011from idpyoidc .configure import Base
1112from idpyoidc .server .client_configure import verify_oidc_client_information
1213from idpyoidc .server .scopes import SCOPE2CLAIMS
1314
1415logger = logging .getLogger (__name__ )
1516
16- OP_DEFAULT_CONFIG = {
17- "preference" : {
18- "subject_types_supported" : ["public" , "pairwise" ],
19- },
17+ _DEFAULT_CONFIG = {
2018 "cookie_handler" : {
2119 "class" : "idpyoidc.server.cookie_handler.CookieHandler" ,
2220 "kwargs" : {
3937 },
4038 },
4139 },
42- "claims_interface" : {"class" : "idpyoidc.server.session.claims.ClaimsInterface" , "kwargs" : {}},
40+ "claims_interface" : {
41+ "class" : "idpyoidc.server.session.claims.ClaimsInterface" ,
42+ "kwargs" : {}
43+ },
44+ "httpc_params" : {"verify" : False , "timeout" : 4 },
45+ "issuer" : "https://{domain}:{port}" ,
46+ "template_dir" : "templates"
47+ }
48+
49+ AS_DEFAULT_CONFIG = copy .deepcopy (_DEFAULT_CONFIG )
50+ _C = {
51+ "authz" : {
52+ "class" : "idpyoidc.server.authz.AuthzHandling" ,
53+ "kwargs" : {
54+ "grant_config" : {
55+ "usage_rules" : {
56+ "authorization_code" : {
57+ "supports_minting" : ["access_token" , "refresh_token" ],
58+ "max_usage" : 1 ,
59+ "expires_in" : 120 # 2 minutes
60+ },
61+ "access_token" : {"expires_in" : 3600 }, # An hour
62+ "refresh_token" : {
63+ "supports_minting" : ["access_token" , "refresh_token" ],
64+ "expires_in" : 86400 , # One day
65+ },
66+ },
67+ "expires_in" : 2592000 , # a month, 30 days
68+ }
69+ }
70+ },
71+ "claims_interface" : {
72+ "class" : "idpyoidc.server.session.claims.ClaimsInterface" ,
73+ "kwargs" : {
74+ "claims_release_points" : ["introspection" , "access_token" ]
75+ }
76+ },
77+ "endpoint" : {
78+ "provider_info" : {
79+ "path" : OAUTH2_SERVER_METADATA_URL [3 :],
80+ "class" : "idpyoidc.server.oauth2.server_metadata.ServerMetadata" ,
81+ "kwargs" : {"client_authn_method" : None },
82+ },
83+ "authorization" : {
84+ "path" : "authorization" ,
85+ "class" : "idpyoidc.server.oauth2.authorization.Authorization" ,
86+ "kwargs" : {
87+ "client_authn_method" : None ,
88+ "claims_parameter_supported" : True ,
89+ "request_parameter_supported" : True ,
90+ "request_uri_parameter_supported" : True ,
91+ "response_types_supported" : ["code" ],
92+ "response_modes_supported" : ["query" , "fragment" , "form_post" ],
93+ },
94+ },
95+ "token" : {
96+ "path" : "token" ,
97+ "class" : "idpyoidc.server.oauth2.token.Token" ,
98+ "kwargs" : {
99+ "client_authn_method" : [
100+ "client_secret_post" ,
101+ "client_secret_basic" ,
102+ "client_secret_jwt" ,
103+ "private_key_jwt" ,
104+ ]
105+ }
106+ }
107+ }
108+ }
109+
110+ AS_DEFAULT_CONFIG .update (_C )
111+
112+ OP_DEFAULT_CONFIG = copy .deepcopy (_DEFAULT_CONFIG )
113+ OP_DEFAULT_CONFIG .update ({
114+ "preference" : {
115+ "subject_types_supported" : ["public" , "pairwise" ],
116+ },
43117 "authz" : {
44118 "class" : "idpyoidc.server.authz.AuthzHandling" ,
45119 "kwargs" : {
52126 "id_token" ,
53127 ],
54128 "max_usage" : 1 ,
129+ 'expires_in' : 120 # 2 minutes
55130 },
56- "access_token" : {},
131+ "access_token" : {'expires_in' : 3600 }, # An hour
57132 "refresh_token" : {
58- "supports_minting" : ["access_token" , "refresh_token" ],
59- "expires_in" : - 1 ,
133+ "supports_minting" : ["access_token" , "refresh_token" , "id_token" ],
134+ "expires_in" : 86400 , # One day
60135 },
61136 },
62- "expires_in" : 43200 ,
137+ "expires_in" : 2592000 , # a month, 30 days
63138 }
64139 },
65140 },
66- "httpc_params" : {"verify" : False , "timeout" : 4 },
141+ "claims_interface" : {
142+ "class" : "idpyoidc.server.session.claims.ClaimsInterface" ,
143+ "kwargs" : {}
144+ },
67145 "endpoint" : {
68146 "provider_info" : {
69147 "path" : ".well-known/openid-configuration" ,
109187 "kwargs" : {"claim_types_supported" : ["normal" , "aggregated" , "distributed" ]},
110188 },
111189 },
112- "issuer" : "https://{domain}:{port}" ,
113- "template_dir" : "templates" ,
114190 "token_handler_args" : {
115191 "jwks_file" : "private/token_jwks.json" ,
116192 "code" : {"kwargs" : {"lifetime" : 600 }},
125201 "id_token" : {"class" : "idpyoidc.server.token.id_token.IDToken" , "kwargs" : {}},
126202 },
127203 "scopes_to_claims" : SCOPE2CLAIMS ,
128- }
204+ })
129205
130- AS_DEFAULT_CONFIG = copy .deepcopy (OP_DEFAULT_CONFIG )
131- AS_DEFAULT_CONFIG ["claims_interface" ] = {
132- "class" : "idpyoidc.server.session.claims.OAuth2ClaimsInterface" ,
133- "kwargs" : {},
134- }
135206
136207
137208class EntityConfiguration (Base ):
@@ -160,15 +231,15 @@ class EntityConfiguration(Base):
160231 }
161232
162233 def __init__ (
163- self ,
164- conf : Dict ,
165- base_path : Optional [str ] = "" ,
166- entity_conf : Optional [List [dict ]] = None ,
167- domain : Optional [str ] = "" ,
168- port : Optional [int ] = 0 ,
169- file_attributes : Optional [List [str ]] = None ,
170- dir_attributes : Optional [List [str ]] = None ,
171- upstream_get : Optional [Callable ] = None ,
234+ self ,
235+ conf : Dict ,
236+ base_path : Optional [str ] = "" ,
237+ entity_conf : Optional [List [dict ]] = None ,
238+ domain : Optional [str ] = "" ,
239+ port : Optional [int ] = 0 ,
240+ file_attributes : Optional [List [str ]] = None ,
241+ dir_attributes : Optional [List [str ]] = None ,
242+ upstream_get : Optional [Callable ] = None ,
172243 ):
173244
174245 conf = copy .deepcopy (conf )
@@ -232,14 +303,14 @@ class OPConfiguration(EntityConfiguration):
232303 )
233304
234305 def __init__ (
235- self ,
236- conf : Dict ,
237- base_path : Optional [str ] = "" ,
238- entity_conf : Optional [List [dict ]] = None ,
239- domain : Optional [str ] = "" ,
240- port : Optional [int ] = 0 ,
241- file_attributes : Optional [List [str ]] = None ,
242- dir_attributes : Optional [List [str ]] = None ,
306+ self ,
307+ conf : Dict ,
308+ base_path : Optional [str ] = "" ,
309+ entity_conf : Optional [List [dict ]] = None ,
310+ domain : Optional [str ] = "" ,
311+ port : Optional [int ] = 0 ,
312+ file_attributes : Optional [List [str ]] = None ,
313+ dir_attributes : Optional [List [str ]] = None ,
243314 ):
244315 super ().__init__ (
245316 conf = conf ,
@@ -256,14 +327,14 @@ class ASConfiguration(EntityConfiguration):
256327 "Authorization server configuration"
257328
258329 def __init__ (
259- self ,
260- conf : Dict ,
261- base_path : Optional [str ] = "" ,
262- entity_conf : Optional [List [dict ]] = None ,
263- domain : Optional [str ] = "" ,
264- port : Optional [int ] = 0 ,
265- file_attributes : Optional [List [str ]] = None ,
266- dir_attributes : Optional [List [str ]] = None ,
330+ self ,
331+ conf : Dict ,
332+ base_path : Optional [str ] = "" ,
333+ entity_conf : Optional [List [dict ]] = None ,
334+ domain : Optional [str ] = "" ,
335+ port : Optional [int ] = 0 ,
336+ file_attributes : Optional [List [str ]] = None ,
337+ dir_attributes : Optional [List [str ]] = None ,
267338 ):
268339 EntityConfiguration .__init__ (
269340 self ,
0 commit comments