@@ -129,7 +129,7 @@ def __init__(self, outgoing, internal_attributes, config, base_url, name):
129129 with open (p ) as key_file :
130130 self .encryption_keys .append (key_file .read ())
131131
132- def get_idp_entity_id (self , context ):
132+ def get_idp_entity_id (self , context , ** kwargs ):
133133 """
134134 :type context: satosa.context.Context
135135 :rtype: str | None
@@ -164,7 +164,7 @@ def get_idp_entity_id(self, context):
164164 )
165165 return entity_id
166166
167- def start_auth (self , context , internal_req ):
167+ def start_auth (self , context , internal_req , ** kwargs ):
168168 """
169169 See super class method satosa.backends.base.BackendModule#start_auth
170170
@@ -184,7 +184,7 @@ def start_auth(self, context, internal_req):
184184
185185 return self .authn_request (context , entity_id )
186186
187- def disco_query (self , context ):
187+ def disco_query (self , context , ** kwargs ):
188188 """
189189 Makes a request to the discovery server
190190
@@ -236,7 +236,7 @@ def construct_requested_authn_context(self, entity_id):
236236
237237 return authn_context
238238
239- def authn_request (self , context , entity_id ):
239+ def authn_request (self , context , entity_id , ** kwargs ):
240240 """
241241 Do an authorization request on idp with given entity id.
242242 This is the start of the authorization.
@@ -294,7 +294,7 @@ def authn_request(self, context, entity_id):
294294 context .state [self .name ] = {"relay_state" : relay_state }
295295 return make_saml_response (binding , ht_args )
296296
297- def authn_response (self , context , binding ):
297+ def authn_response (self , context , binding , ** kwargs ):
298298 """
299299 Endpoint for the idp response
300300 :type context: satosa.context,Context
@@ -326,11 +326,12 @@ def authn_response(self, context, binding):
326326 raise SATOSAAuthenticationError (context .state , errmsg )
327327 del self .outstanding_queries [req_id ]
328328
329- # check if the relay_state matches the cookie state
330- if context .state [self .name ]["relay_state" ] != context .request ["RelayState" ]:
331- satosa_logging (logger , logging .DEBUG ,
332- "State did not match relay state for state" , context .state )
333- raise SATOSAAuthenticationError (context .state , "State did not match relay state" )
329+ # if the response relay_state exists it must match that from the request
330+ if self .name in context .state and "relay_state" in context .state [self .name ]:
331+ if context .state [self .name ]["relay_state" ] != context .request ["RelayState" ]:
332+ logger .debug ("State did not match relay state for state" , extra = {'state' : context .state })
333+ raise SATOSAAuthenticationError (context .state , "State did not match relay state" )
334+ del context .state [self .name ]
334335
335336 context .decorate (Context .KEY_BACKEND_METADATA_STORE , self .sp .metadata )
336337 if self .config .get (SAMLBackend .KEY_MEMORIZE_IDP ):
@@ -340,7 +341,7 @@ def authn_response(self, context, binding):
340341 context .state .pop (Context .KEY_FORCE_AUTHN , None )
341342 return self .auth_callback_func (context , self ._translate_response (authn_response , context .state ))
342343
343- def disco_response (self , context ):
344+ def disco_response (self , context , ** kwargs ):
344345 """
345346 Endpoint for the discovery server response
346347
@@ -406,7 +407,7 @@ def _translate_response(self, response, state):
406407 json .dumps (response .ava , indent = 4 ), state )
407408 return internal_resp
408409
409- def _metadata_endpoint (self , context ):
410+ def _metadata_endpoint (self , context , ** kwargs ):
410411 """
411412 Endpoint for retrieving the backend metadata
412413 :type context: satosa.context.Context
0 commit comments