@@ -129,7 +129,7 @@ def __init__(self, outgoing, internal_attributes, config, base_url, name):
129
129
with open (p ) as key_file :
130
130
self .encryption_keys .append (key_file .read ())
131
131
132
- def get_idp_entity_id (self , context ):
132
+ def get_idp_entity_id (self , context , ** kwargs ):
133
133
"""
134
134
:type context: satosa.context.Context
135
135
:rtype: str | None
@@ -164,7 +164,7 @@ def get_idp_entity_id(self, context):
164
164
)
165
165
return entity_id
166
166
167
- def start_auth (self , context , internal_req ):
167
+ def start_auth (self , context , internal_req , ** kwargs ):
168
168
"""
169
169
See super class method satosa.backends.base.BackendModule#start_auth
170
170
@@ -184,7 +184,7 @@ def start_auth(self, context, internal_req):
184
184
185
185
return self .authn_request (context , entity_id )
186
186
187
- def disco_query (self , context ):
187
+ def disco_query (self , context , ** kwargs ):
188
188
"""
189
189
Makes a request to the discovery server
190
190
@@ -236,7 +236,7 @@ def construct_requested_authn_context(self, entity_id):
236
236
237
237
return authn_context
238
238
239
- def authn_request (self , context , entity_id ):
239
+ def authn_request (self , context , entity_id , ** kwargs ):
240
240
"""
241
241
Do an authorization request on idp with given entity id.
242
242
This is the start of the authorization.
@@ -294,7 +294,7 @@ def authn_request(self, context, entity_id):
294
294
context .state [self .name ] = {"relay_state" : relay_state }
295
295
return make_saml_response (binding , ht_args )
296
296
297
- def authn_response (self , context , binding ):
297
+ def authn_response (self , context , binding , ** kwargs ):
298
298
"""
299
299
Endpoint for the idp response
300
300
:type context: satosa.context,Context
@@ -326,11 +326,12 @@ def authn_response(self, context, binding):
326
326
raise SATOSAAuthenticationError (context .state , errmsg )
327
327
del self .outstanding_queries [req_id ]
328
328
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 ]
334
335
335
336
context .decorate (Context .KEY_BACKEND_METADATA_STORE , self .sp .metadata )
336
337
if self .config .get (SAMLBackend .KEY_MEMORIZE_IDP ):
@@ -340,7 +341,7 @@ def authn_response(self, context, binding):
340
341
context .state .pop (Context .KEY_FORCE_AUTHN , None )
341
342
return self .auth_callback_func (context , self ._translate_response (authn_response , context .state ))
342
343
343
- def disco_response (self , context ):
344
+ def disco_response (self , context , ** kwargs ):
344
345
"""
345
346
Endpoint for the discovery server response
346
347
@@ -406,7 +407,7 @@ def _translate_response(self, response, state):
406
407
json .dumps (response .ava , indent = 4 ), state )
407
408
return internal_resp
408
409
409
- def _metadata_endpoint (self , context ):
410
+ def _metadata_endpoint (self , context , ** kwargs ):
410
411
"""
411
412
Endpoint for retrieving the backend metadata
412
413
:type context: satosa.context.Context
0 commit comments