1
1
"""
2
- SATOSA microservice that uses an identifier asserted by
2
+ SATOSA microservice that uses an identifier asserted by
3
3
the home organization SAML IdP as a key to search an LDAP
4
4
directory for a record and then consume attributes from
5
5
the record and assert them to the receiving SP.
@@ -33,9 +33,9 @@ def constructFilterValue(self, candidate, data):
33
33
Construct and return a LDAP directory search filter value from the
34
34
candidate identifier.
35
35
36
- Argument 'canidate' is a dictionary with one required key and
36
+ Argument 'canidate' is a dictionary with one required key and
37
37
two optional keys:
38
-
38
+
39
39
key required value
40
40
--------------- -------- ---------------------------------
41
41
attribute_names Y list of identifier names
@@ -50,7 +50,7 @@ def constructFilterValue(self, candidate, data):
50
50
If the attribute_names list consists of more than one identifier
51
51
name then the values of the identifiers will be concatenated together
52
52
to create the filter value.
53
-
53
+
54
54
If one of the identifier names in the attribute_names is the string
55
55
'name_id' then the NameID value with format name_id_format
56
56
will be concatenated to the filter value.
@@ -87,9 +87,9 @@ def constructFilterValue(self, candidate, data):
87
87
if candidate ['name_id_format' ] in name_id :
88
88
nameid_value = name_id [candidate ['name_id_format' ]]
89
89
90
- # Only add the NameID value asserted by the IdP if it is not already
90
+ # Only add the NameID value asserted by the IdP if it is not already
91
91
# in the list of values. This is necessary because some non-compliant IdPs
92
- # have been known, for example, to assert the value of eduPersonPrincipalName
92
+ # have been known, for example, to assert the value of eduPersonPrincipalName
93
93
# in the value for SAML2 persistent NameID as well as asserting
94
94
# eduPersonPrincipalName.
95
95
if nameid_value not in values :
@@ -132,7 +132,7 @@ def process(self, context, data):
132
132
config = self .config
133
133
configClean = copy .deepcopy (config )
134
134
if 'bind_password' in configClean :
135
- configClean ['bind_password' ] = 'XXXXXXXX'
135
+ configClean ['bind_password' ] = 'XXXXXXXX'
136
136
137
137
satosa_logging (logger , logging .DEBUG , "{} Using default configuration {}" .format (logprefix , configClean ), context .state )
138
138
@@ -150,9 +150,9 @@ def process(self, context, data):
150
150
config = self .config [spEntityID ]
151
151
configClean = copy .deepcopy (config )
152
152
if 'bind_password' in configClean :
153
- configClean ['bind_password' ] = 'XXXXXXXX'
153
+ configClean ['bind_password' ] = 'XXXXXXXX'
154
154
satosa_logging (logger , logging .DEBUG , "{} For SP {} using configuration {}" .format (logprefix , spEntityID , configClean ), context .state )
155
-
155
+
156
156
# Obtain configuration details from the per-SP configuration or the default configuration
157
157
try :
158
158
if 'ldap_url' in config :
@@ -201,11 +201,20 @@ def process(self, context, data):
201
201
on_ldap_search_result_empty = self .config ['on_ldap_search_result_empty' ]
202
202
else :
203
203
on_ldap_search_result_empty = None
204
+ if 'ignore' in config :
205
+ ignore = True
206
+ else :
207
+ ignore = False
204
208
205
209
except KeyError as err :
206
210
satosa_logging (logger , logging .ERROR , "{} Configuration '{}' is missing" .format (logprefix , err ), context .state )
207
211
return super ().process (context , data )
208
212
213
+ # Ignore this SP entirely if so configured.
214
+ if ignore :
215
+ satosa_logging (logger , logging .INFO , "{} Ignoring SP {}" .format (logprefix , spEntityID ), None )
216
+ return super ().process (context , data )
217
+
209
218
# The list of values for the LDAP search filters that will be tried in order to find the
210
219
# LDAP directory record for the user.
211
220
filterValues = []
@@ -253,7 +262,7 @@ def process(self, context, data):
253
262
satosa_logging (logger , logging .WARN , "{} LDAP server returned {} records using IdP asserted attribute {}" .format (logprefix , len (responses ), identifier ), context .state )
254
263
record = responses [0 ]
255
264
break
256
-
265
+
257
266
except Exception as err :
258
267
satosa_logging (logger , logging .ERROR , "{} Caught exception: {}" .format (logprefix , err ), context .state )
259
268
return super ().process (context , data )
0 commit comments