Skip to content

Commit 44153eb

Browse files
authored
Merge pull request #135 from italia/acrspid
spid backend acr selection
2 parents 3cc95fc + 95273d0 commit 44153eb

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

example/backends/spidsaml2.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,25 @@ def authn_response(self, context, binding):
562562
recipient = _sp_config["service"]["sp"]["endpoints"][
563563
"assertion_consumer_service"
564564
][0][0]
565-
authn_context_classref = self.config["acr_mapping"][""]
566565

567-
issuer = authn_response.response.issuer
566+
# ACR
567+
issuer = authn_response.response.issuer.text.strip()
568+
acr_map :dict = {}
569+
570+
try:
571+
acr_map = self.config["acr_mapping"]
572+
except Exception as e:
573+
logger.warning(
574+
"acr_mapping not defined in the spid backend"
575+
)
576+
return self.handle_error(
577+
**{
578+
"message": "acr_mapping not defined in the spid backend",
579+
"troubleshoot": "Please contact the administrators of the platform and tell them to configure properly the acr_mapping in the SPID/CIE backend"
580+
}
581+
)
582+
acr_default = acr_map.get("", "https://www.spid.gov.it/SpidL2")
583+
authn_context_classref = acr_map.get(issuer, acr_default)
568584

569585
# this will get the entity name in state
570586
if len(context.state.keys()) < 2:

0 commit comments

Comments
 (0)