@@ -40,9 +40,9 @@ class Authorization(Service):
4040 }
4141
4242 _callback_path = {
43- "redirect_uris" : { # based on response_types
44- "code " : "authz_cb" ,
45- "implicit " : "authz_im_cb" ,
43+ "redirect_uris" : { # based on response_mode
44+ "query " : "authz_cb" ,
45+ "fragment " : "authz_im_cb" ,
4646 # "form_post": "form"
4747 }
4848 }
@@ -100,18 +100,21 @@ def post_parse_response(self, response, **kwargs):
100100 pass
101101 return response
102102
103- def _do_flow (self , flow_type , response_types , context ):
104- if flow_type == "code " :
103+ def _do_flow (self , flow_type , response_types , context ) -> str :
104+ if flow_type == "query " :
105105 if "code" in response_types :
106- return True
107- elif flow_type in [ "implicit" , "hybrid" ] :
106+ return "query"
107+ elif flow_type == "fragment" :
108108 if implicit_response_types (response_types ):
109- return True
109+ return "fragment"
110110 elif flow_type == 'form_post' :
111111 rm = context .get_preference ('response_modes_supported' )
112112 if rm and 'form_post' in rm :
113- return context .config .conf .get ("separate_form_post_cb" , True )
114- return False
113+ if context .config .conf .get ("separate_form_post_cb" , True ):
114+ return "form_post"
115+ else :
116+ return "query"
117+ return ''
115118
116119 def _do_redirect_uris (self , base_url , hex , context , callback_uris , response_types ):
117120 _redirect_uris = context .get_preference ("redirect_uris" , [])
@@ -127,16 +130,20 @@ def _do_redirect_uris(self, base_url, hex, context, callback_uris, response_type
127130 pass
128131 else :
129132 callback_uris ["redirect_uris" ] = {}
130- for flow_type , path in self ._callback_path ["redirect_uris" ].items ():
131- if self ._do_flow (flow_type , response_types , context ):
133+ for flow_type in self ._callback_path ["redirect_uris" ].keys ():
134+ _var = self ._do_flow (flow_type , response_types , context )
135+ if _var :
136+ _path = self ._callback_path ["redirect_uris" ][_var ]
132137 callback_uris ["redirect_uris" ][flow_type ] = [
133- self .get_uri (base_url , path , hex )
138+ self .get_uri (base_url , _path , hex )
134139 ]
135140 else :
136141 callback_uris ["redirect_uris" ] = {}
137- for flow_type , path in self ._callback_path ["redirect_uris" ].items ():
138- if self ._do_flow (flow_type , response_types , context ):
139- callback_uris ["redirect_uris" ][flow_type ] = [self .get_uri (base_url , path , hex )]
142+ for flow_type in self ._callback_path ["redirect_uris" ].keys ():
143+ _var = self ._do_flow (flow_type , response_types , context )
144+ if _var :
145+ _path = self ._callback_path ["redirect_uris" ][_var ]
146+ callback_uris ["redirect_uris" ][flow_type ] = [self .get_uri (base_url , _path , hex )]
140147 return callback_uris
141148
142149 def construct_uris (
0 commit comments