Skip to content

Commit bcd2388

Browse files
committed
Memorize idp only if auth was successful
This also means that we memorize the IdP regardless of the disco. Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 71e114d commit bcd2388

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/satosa/backends/saml2.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def authn_response(self, context, binding):
317317
raise SATOSAAuthenticationError(context.state, "State did not match relay state")
318318

319319
context.decorate(Context.KEY_BACKEND_METADATA_STORE, self.sp.metadata)
320-
320+
if self.config.get(SAMLBackend.KEY_MEMORIZE_DISCO_IDP):
321+
issuer = authn_response.response.issuer.text.strip()
322+
context.state[Context.KEY_MEMORIZED_DISCO_IDP] = issuer
321323
context.state.pop(self.name, None)
322324
context.state.pop(Context.KEY_FORCE_AUTHN, None)
323325
return self.auth_callback_func(context, self._translate_response(authn_response, context.state))
@@ -341,9 +343,6 @@ def disco_response(self, context):
341343
satosa_logging(logger, logging.DEBUG, "No IDP chosen for state", state, exc_info=True)
342344
raise SATOSAAuthenticationError(state, "No IDP chosen") from err
343345

344-
if self.config.get(SAMLBackend.KEY_MEMORIZE_DISCO_IDP):
345-
context.state[Context.KEY_MEMORIZED_DISCO_IDP] = entity_id
346-
347346
return self.authn_request(context, entity_id)
348347

349348
def _translate_response(self, response, state):

0 commit comments

Comments
 (0)