Skip to content

Commit f1075c1

Browse files
skorandac00kiemon5ter
authored andcommitted
Ignore SP if so configured
Add functionality to allow configuration to ignore a particular SP so that no resolution of attributes from LDAP is attempted for that SP. Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 664d329 commit f1075c1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

example/plugins/microservices/ldap_attribute_store.yaml.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ config:
5353
- attribute_names: [eppn]
5454
user_id_from_attrs:
5555
- uid
56+
# The microservice may be configured to ignore a particular SP.
57+
https://another.sp.myserver.edu
58+
ignore: true
59+

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
SATOSA microservice that uses an identifier asserted by
2+
SATOSA microservice that uses an identifier asserted by
33
the home organization SAML IdP as a key to search an LDAP
44
directory for a record and then consume attributes from
55
the record and assert them to the receiving SP.
@@ -33,9 +33,9 @@ def constructFilterValue(self, candidate, data):
3333
Construct and return a LDAP directory search filter value from the
3434
candidate identifier.
3535
36-
Argument 'canidate' is a dictionary with one required key and
36+
Argument 'canidate' is a dictionary with one required key and
3737
two optional keys:
38-
38+
3939
key required value
4040
--------------- -------- ---------------------------------
4141
attribute_names Y list of identifier names
@@ -50,7 +50,7 @@ def constructFilterValue(self, candidate, data):
5050
If the attribute_names list consists of more than one identifier
5151
name then the values of the identifiers will be concatenated together
5252
to create the filter value.
53-
53+
5454
If one of the identifier names in the attribute_names is the string
5555
'name_id' then the NameID value with format name_id_format
5656
will be concatenated to the filter value.
@@ -87,9 +87,9 @@ def constructFilterValue(self, candidate, data):
8787
if candidate['name_id_format'] in name_id:
8888
nameid_value = name_id[candidate['name_id_format']]
8989

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
9191
# 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
9393
# in the value for SAML2 persistent NameID as well as asserting
9494
# eduPersonPrincipalName.
9595
if nameid_value not in values:
@@ -132,7 +132,7 @@ def process(self, context, data):
132132
config = self.config
133133
configClean = copy.deepcopy(config)
134134
if 'bind_password' in configClean:
135-
configClean['bind_password'] = 'XXXXXXXX'
135+
configClean['bind_password'] = 'XXXXXXXX'
136136

137137
satosa_logging(logger, logging.DEBUG, "{} Using default configuration {}".format(logprefix, configClean), context.state)
138138

@@ -150,9 +150,9 @@ def process(self, context, data):
150150
config = self.config[spEntityID]
151151
configClean = copy.deepcopy(config)
152152
if 'bind_password' in configClean:
153-
configClean['bind_password'] = 'XXXXXXXX'
153+
configClean['bind_password'] = 'XXXXXXXX'
154154
satosa_logging(logger, logging.DEBUG, "{} For SP {} using configuration {}".format(logprefix, spEntityID, configClean), context.state)
155-
155+
156156
# Obtain configuration details from the per-SP configuration or the default configuration
157157
try:
158158
if 'ldap_url' in config:
@@ -201,11 +201,20 @@ def process(self, context, data):
201201
on_ldap_search_result_empty = self.config['on_ldap_search_result_empty']
202202
else:
203203
on_ldap_search_result_empty = None
204+
if 'ignore' in config:
205+
ignore = True
206+
else:
207+
ignore = False
204208

205209
except KeyError as err:
206210
satosa_logging(logger, logging.ERROR, "{} Configuration '{}' is missing".format(logprefix, err), context.state)
207211
return super().process(context, data)
208212

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+
209218
# The list of values for the LDAP search filters that will be tried in order to find the
210219
# LDAP directory record for the user.
211220
filterValues = []
@@ -253,7 +262,7 @@ def process(self, context, data):
253262
satosa_logging(logger, logging.WARN, "{} LDAP server returned {} records using IdP asserted attribute {}".format(logprefix, len(responses), identifier), context.state)
254263
record = responses[0]
255264
break
256-
265+
257266
except Exception as err:
258267
satosa_logging(logger, logging.ERROR, "{} Caught exception: {}".format(logprefix, err), context.state)
259268
return super().process(context, data)

0 commit comments

Comments
 (0)