@@ -43,27 +43,24 @@ def index():
4343
4444@oidc_rp_views .route ('/rp' )
4545def rp ():
46- try :
47- iss = request .args ['iss' ]
48- except KeyError :
49- link = ''
50- else :
51- link = iss
46+ iss = request .args ['dyn_iss' ]
47+ if not iss :
48+ iss = request .args ['static_iss' ]
5249
53- try :
50+ if not iss :
5451 uid = request .args ['uid' ]
55- except KeyError :
52+ else :
5653 uid = ''
5754
58- if link or uid :
55+ if iss or uid :
5956 if uid :
6057 args = {'user_id' : uid }
6158 else :
6259 args = {}
6360
64- session ['op_hash ' ] = link
61+ session ['op_identifier ' ] = iss
6562 try :
66- result = current_app .rph .begin (link , ** args )
63+ result = current_app .rph .begin (iss , ** args )
6764 except Exception as err :
6865 return make_response ('Something went wrong:{}' .format (err ), 400 )
6966 else :
@@ -74,13 +71,16 @@ def rp():
7471 return render_template ('opbyuid.html' , providers = _providers )
7572
7673
77- def get_rp (op_hash ):
74+ def get_rp (op_identifier ):
7875 try :
79- _iss = current_app .rph .hash2issuer [op_hash ]
76+ _iss = current_app .rph .hash2issuer [op_identifier ]
8077 except KeyError :
81- logger .error ('Unkown issuer: {} not among {}' .format (
82- op_hash , list (current_app .rph .hash2issuer .keys ())))
83- return make_response ("Unknown hash: {}" .format (op_hash ), 400 )
78+ try :
79+ rp = current_app .rph .issuer2rp [op_identifier ]
80+ except KeyError :
81+ logger .error ('Unkown issuer: {} not among {}' .format (
82+ op_identifier , list (current_app .rph .hash2issuer .keys ())))
83+ return make_response ("Unknown hash: {}" .format (op_identifier ), 400 )
8484 else :
8585 try :
8686 rp = current_app .rph .issuer2rp [_iss ]
@@ -91,8 +91,8 @@ def get_rp(op_hash):
9191 return rp
9292
9393
94- def finalize (op_hash , request_args ):
95- rp = get_rp (op_hash )
94+ def finalize (op_identifier , request_args ):
95+ rp = get_rp (op_identifier )
9696
9797 if hasattr (rp , 'status_code' ) and rp .status_code != 200 :
9898 logger .error (rp .response [0 ].decode ())
@@ -151,22 +151,22 @@ def finalize(op_hash, request_args):
151151 return make_response (res ['error' ], 400 )
152152
153153
154- def get_ophash_by_cb_uri (url : str ):
154+ def get_op_identifier_by_cb_uri (url : str ):
155155 uri = splitquery (url )[0 ]
156- clients = current_app .rp_config . clients
157- for k , v in clients . items ():
156+ for k , v in current_app .rph . issuer2rp . items ():
157+ _cntx = v . get_service_context ()
158158 for endpoint in ("redirect_uris" ,
159159 "post_logout_redirect_uris" ,
160160 "frontchannel_logout_uri" ,
161161 "backchannel_logout_uri" ):
162- if uri in clients [ k ] .get (endpoint , []):
162+ if uri in _cntx .get (endpoint , []):
163163 return k
164164
165165
166- @oidc_rp_views .route ('/authz_cb/<op_hash >' )
167- def authz_cb (op_hash ):
168- op_hash = get_ophash_by_cb_uri (request .url )
169- return finalize (op_hash , request .args )
166+ @oidc_rp_views .route ('/authz_cb/<op_identifier >' )
167+ def authz_cb (op_identifier ):
168+ op_identifier = get_op_identifier_by_cb_uri (request .url )
169+ return finalize (op_identifier , request .args )
170170
171171
172172@oidc_rp_views .errorhandler (werkzeug .exceptions .BadRequest )
@@ -177,12 +177,12 @@ def handle_bad_request(e):
177177@oidc_rp_views .route ('/repost_fragment' )
178178def repost_fragment ():
179179 args = compact (parse_qs (request .args ['url_fragment' ]))
180- op_hash = request .args ['op_hash ' ]
181- return finalize (op_hash , args )
180+ op_identifier = request .args ['op_identifier ' ]
181+ return finalize (op_identifier , args )
182182
183183
184184@oidc_rp_views .route ('/ihf_cb' )
185- def ihf_cb (self , op_hash = '' , ** kwargs ):
185+ def ihf_cb (self , op_identifier = '' , ** kwargs ):
186186 logger .debug ('implicit_hybrid_flow kwargs: {}' .format (kwargs ))
187187 return render_template ('repost_fragment.html' )
188188
@@ -191,11 +191,11 @@ def ihf_cb(self, op_hash='', **kwargs):
191191def session_iframe (): # session management
192192 logger .debug ('session_iframe request_args: {}' .format (request .args ))
193193
194- _rp = get_rp (session ['op_hash ' ])
194+ _rp = get_rp (session ['op_identifier ' ])
195195 _context = _rp .client_get ("service_context" )
196196 session_change_url = "{}/session_change" .format (_context .base_url )
197197
198- _issuer = current_app .rph .hash2issuer [session ['op_hash ' ]]
198+ _issuer = current_app .rph .hash2issuer [session ['op_identifier ' ]]
199199 args = {
200200 'client_id' : session ['client_id' ],
201201 'session_state' : session ['session_state' ],
@@ -209,8 +209,8 @@ def session_iframe(): # session management
209209
210210@oidc_rp_views .route ('/session_change' )
211211def session_change ():
212- logger .debug ('session_change: {}' .format (session ['op_hash ' ]))
213- _rp = get_rp (session ['op_hash ' ])
212+ logger .debug ('session_change: {}' .format (session ['op_identifier ' ]))
213+ _rp = get_rp (session ['op_identifier ' ])
214214
215215 # If there is an ID token send it along as a id_token_hint
216216 _aserv = _rp .client_get ("service" , 'authorization' )
@@ -228,10 +228,10 @@ def session_change():
228228
229229
230230# post_logout_redirect_uri
231- @oidc_rp_views .route ('/session_logout/<op_hash >' )
232- def session_logout (op_hash ):
233- op_hash = get_ophash_by_cb_uri (request .url )
234- _rp = get_rp (op_hash )
231+ @oidc_rp_views .route ('/session_logout/<op_identifier >' )
232+ def session_logout (op_identifier ):
233+ op_identifier = get_op_identifier_by_cb_uri (request .url )
234+ _rp = get_rp (op_identifier )
235235 logger .debug ('post_logout' )
236236 return "Post logout from {}" .format (_rp .client_get ("service_context" ).issuer )
237237
@@ -245,9 +245,9 @@ def logout():
245245 return redirect (_info ['url' ], 303 )
246246
247247
248- @oidc_rp_views .route ('/bc_logout/<op_hash >' , methods = ['GET' , 'POST' ])
249- def backchannel_logout (op_hash ):
250- _rp = get_rp (op_hash )
248+ @oidc_rp_views .route ('/bc_logout/<op_identifier >' , methods = ['GET' , 'POST' ])
249+ def backchannel_logout (op_identifier ):
250+ _rp = get_rp (op_identifier )
251251 try :
252252 _state = rp_handler .backchannel_logout (_rp , request .data )
253253 except Exception as err :
@@ -258,9 +258,9 @@ def backchannel_logout(op_hash):
258258 return "OK"
259259
260260
261- @oidc_rp_views .route ('/fc_logout/<op_hash >' , methods = ['GET' , 'POST' ])
262- def frontchannel_logout (op_hash ):
263- _rp = get_rp (op_hash )
261+ @oidc_rp_views .route ('/fc_logout/<op_identifier >' , methods = ['GET' , 'POST' ])
262+ def frontchannel_logout (op_identifier ):
263+ _rp = get_rp (op_identifier )
264264 sid = request .args ['sid' ]
265265 _iss = request .args ['iss' ]
266266 if _iss != _rp .client_get ("service_context" ).get ('issuer' ):
0 commit comments