@@ -1030,6 +1030,7 @@ class SAMLUnsolicitedFrontend(SAMLFrontend):
1030
1030
KEY_ENDPOINT = "endpoint"
1031
1031
KEY_DISCO_URL_WHITE = "discovery_service_url_whitelist"
1032
1032
KEY_DISCO_POLICY_WHITE = "discovery_service_policy_whitelist"
1033
+ KEY_QUERY_IDP = "authId"
1033
1034
KEY_QUERY_SP = "providerId"
1034
1035
KEY_QUERY_ACS = "shire"
1035
1036
KEY_QUERY_RELAY = "target"
@@ -1084,12 +1085,15 @@ def unsolicited_endpoint(self, context):
1084
1085
"""
1085
1086
request = context .request
1086
1087
1088
+ target_idp_entity_id = request .get (self .KEY_QUERY_IDP , None )
1087
1089
target_sp_entity_id = request .get (self .KEY_QUERY_SP , None )
1088
1090
target_sp_acs_url = request .get (self .KEY_QUERY_ACS , None )
1089
1091
target_sp_relay_state_url = request .get (self .KEY_QUERY_RELAY , None )
1090
1092
requested_disco_url = request .get (self .KEY_QUERY_DISCO_URL , None )
1091
1093
requested_disco_policy = request .get (self .KEY_QUERY_DISCO_POLICY , None )
1092
1094
1095
+ logger .debug ("Unsolicited target authenticating IdP is {}" .format (
1096
+ target_idp_entity_id ))
1093
1097
logger .debug ("Unsolicited target SP is {}" .format (target_sp_entity_id ))
1094
1098
logger .debug ("Unsolicited ACS URL is {}" .format (target_sp_acs_url ))
1095
1099
logger .debug ("Unsolicited relay state is {}" .format (
@@ -1225,5 +1229,18 @@ def unsolicited_endpoint(self, context):
1225
1229
context .decorate (self .KEY_SAML_DISCOVERY_SERVICE_POLICY ,
1226
1230
requested_disco_policy )
1227
1231
1232
+ # If provided and known in the SAML metadata set the entityID for
1233
+ # the IdP to use for authentication.
1234
+ if target_idp_entity_id :
1235
+ try :
1236
+ target_idp_metadata = self .idp .metadata [target_idp_entity_id ]
1237
+ except KeyError :
1238
+ msg = "Target IdP with entityID {} is unknown in metadata"
1239
+ msg = msg .format (target_idp_entity_id )
1240
+ satosa_logging (logger , logging .ERROR , msg , context .state )
1241
+ raise SATOSAError (msg )
1242
+
1243
+ context .decorate (Context .KEY_TARGET_ENTITYID , target_idp_entity_id )
1244
+
1228
1245
# Handle the authn request use the base class.
1229
1246
return self ._handle_authn_request (context , BINDING_HTTP_POST , self .idp )
0 commit comments