@@ -1028,12 +1028,17 @@ class SAMLUnsolicitedFrontend(SAMLFrontend):
1028
1028
SAML standard.
1029
1029
"""
1030
1030
KEY_ENDPOINT = "endpoint"
1031
- KEY_DISCO_WHITE = "discovery_service_whitelist"
1031
+ KEY_DISCO_URL_WHITE = "discovery_service_url_whitelist"
1032
+ KEY_DISCO_POLICY_WHITE = "discovery_service_policy_whitelist"
1032
1033
KEY_QUERY_SP = "providerId"
1033
1034
KEY_QUERY_ACS = "shire"
1034
1035
KEY_QUERY_RELAY = "target"
1035
- KEY_QUERY_DISCO = "discoveryURL"
1036
+ KEY_QUERY_DISCO_URL = "discoveryURL"
1037
+ KEY_QUERY_DISCO_POLICY = "discoveryPolicy"
1036
1038
KEY_SAML_DISCOVERY_SERVICE_URL = SAMLBackend .KEY_SAML_DISCOVERY_SERVICE_URL
1039
+ KEY_SAML_DISCOVERY_SERVICE_POLICY = (
1040
+ SAMLBackend .KEY_SAML_DISCOVERY_SERVICE_POLICY
1041
+ )
1037
1042
KEY_UNSOLICITED = "unsolicited"
1038
1043
1039
1044
def __init__ (self , auth_req_callback_func , internal_attributes , config ,
@@ -1082,14 +1087,17 @@ def unsolicited_endpoint(self, context):
1082
1087
target_sp_entity_id = request .get (self .KEY_QUERY_SP , None )
1083
1088
target_sp_acs_url = request .get (self .KEY_QUERY_ACS , None )
1084
1089
target_sp_relay_state_url = request .get (self .KEY_QUERY_RELAY , None )
1085
- requested_disco_url = request .get (self .KEY_QUERY_DISCO , None )
1090
+ requested_disco_url = request .get (self .KEY_QUERY_DISCO_URL , None )
1091
+ requested_disco_policy = request .get (self .KEY_QUERY_DISCO_POLICY , None )
1086
1092
1087
1093
logger .debug ("Unsolicited target SP is {}" .format (target_sp_entity_id ))
1088
1094
logger .debug ("Unsolicited ACS URL is {}" .format (target_sp_acs_url ))
1089
1095
logger .debug ("Unsolicited relay state is {}" .format (
1090
1096
target_sp_relay_state_url ))
1091
1097
logger .debug ("Unsolicted discovery URL is {}" .format (
1092
1098
requested_disco_url ))
1099
+ logger .debug ("Unsolicted discovery policy is {}" .format (
1100
+ requested_disco_policy ))
1093
1101
1094
1102
# We only proceed with known federated SPs.
1095
1103
try :
@@ -1194,15 +1202,28 @@ def unsolicited_endpoint(self, context):
1194
1202
# If provided and is whitelisted set the discovery service to use.
1195
1203
if requested_disco_url :
1196
1204
allowed = (self .config [self .KEY_UNSOLICITED ]
1197
- .get (self .KEY_DISCO_WHITE ))
1205
+ .get (self .KEY_DISCO_URL_WHITE ))
1198
1206
if requested_disco_url not in allowed :
1199
- msg = "Discovery service {} not allowed"
1207
+ msg = "Discovery service URL {} not allowed"
1200
1208
msg = msg .format (requested_disco_url )
1201
1209
satosa_logging (logger , logging .ERROR , msg , context .state )
1202
1210
raise SATOSAError (msg )
1203
1211
1204
1212
context .decorate (self .KEY_SAML_DISCOVERY_SERVICE_URL ,
1205
1213
requested_disco_url )
1206
1214
1215
+ # If provided and is whitelisted set the discovery policy to use.
1216
+ if requested_disco_policy :
1217
+ allowed = (self .config [self .KEY_UNSOLICITED ]
1218
+ .get (self .KEY_DISCO_POLICY_WHITE ))
1219
+ if requested_disco_policy not in allowed :
1220
+ msg = "Discovery service policy {} not allowed"
1221
+ msg = msg .format (requested_disco_policy )
1222
+ satosa_logging (logger , logging .ERROR , msg , context .state )
1223
+ raise SATOSAError (msg )
1224
+
1225
+ context .decorate (self .KEY_SAML_DISCOVERY_SERVICE_POLICY ,
1226
+ requested_disco_policy )
1227
+
1207
1228
# Handle the authn request use the base class.
1208
1229
return self ._handle_authn_request (context , BINDING_HTTP_POST , self .idp )
0 commit comments