66from flask .app import Flask
77
88from oidcrp import RPHandler
9- from oidcrp .util import load_yaml_config
9+ from oidcrp .configure import Configuration
1010
1111dir_path = os .path .dirname (os .path .realpath (__file__ ))
1212
1313
1414def init_oidc_rp_handler (app ):
15- verify_ssl = app .config .get ('VERIFY_SSL' )
16- httpc_params = {"verify" : verify_ssl }
17-
18- _cert = app .config .get ("CLIENT_CERT" )
19- _key = app .config .get ("CLIENT_KEY" )
20- if _cert and _key :
21- httpc_params ["cert" ] = (_cert , _key )
22- elif _cert :
23- httpc_params ["cert" ] = _cert
24-
25- hash_seed = app .config .get ('HASH_SEED' )
26- if not hash_seed :
27- hash_seed = "BabyHoldOn"
28-
29- rp_keys_conf = app .config .get ('RP_KEYS' )
30- if rp_keys_conf is None :
31- rp_keys_conf = app .config .get ('OIDC_KEYS' )
32-
33- if rp_keys_conf :
34- _kj = init_key_jar (** rp_keys_conf )
35- _path = rp_keys_conf ['public_path' ]
15+ _rp_conf = app .rp_config
16+
17+ if _rp_conf .rp_keys :
18+ _kj = init_key_jar (** _rp_conf .rp_keys )
19+ _path = _rp_conf .rp_keys ['public_path' ]
3620 # removes ./ and / from the begin of the string
3721 _path = re .sub ('^(.)/' , '' , _path )
3822 else :
3923 _kj = KeyJar ()
4024 _path = ''
41- _kj .httpc_params = httpc_params
25+ _kj .httpc_params = _rp_conf . httpc_params
4226
43- rph = RPHandler (base_url = app . config . get ( 'BASEURL' ) ,
44- hash_seed = hash_seed , keyjar = _kj , jwks_path = _path ,
45- client_configs = app . config . get ( 'CLIENTS' ) ,
46- services = app . config . get ( 'SERVICES' ) , httpc_params = httpc_params )
27+ rph = RPHandler (base_url = _rp_conf . base_url ,
28+ hash_seed = _rp_conf . hash_seed , keyjar = _kj , jwks_path = _path ,
29+ client_configs = _rp_conf . clients ,
30+ services = _rp_conf . services , httpc_params = _rp_conf . httpc_params )
4731
4832 return rph
4933
@@ -52,14 +36,8 @@ def oidc_provider_init_app(config_file, name=None, **kwargs):
5236 name = name or __name__
5337 app = Flask (name , static_url_path = '' , ** kwargs )
5438
55- if config_file .endswith ('.yaml' ):
56- app .config .update (load_yaml_config (config_file ))
57- elif config_file .endswith ('.py' ):
58- app .config .from_pyfile (os .path .join (dir_path , config_file ))
59- else :
60- raise ValueError ('Unknown configuration format' )
61-
62- app .config ['SECRET_KEY' ] = os .urandom (12 ).hex ()
39+ app .rp_config = Configuration .create_from_config_file (config_file )
40+ # app.config['SECRET_KEY'] = os.urandom(12).hex()
6341
6442 app .users = {'test_user' : {'name' : 'Testing Name' }}
6543
0 commit comments