Skip to content

Commit 82c0f6e

Browse files
Merge pull request #141 from jkakavas/idp_blacklisting
Idp blacklisting
2 parents 989791e + 1c52d2e commit 82c0f6e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

example/plugins/backends/saml2_backend.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module: satosa.backends.saml2.SAMLBackend
22
name: Saml2
33
config:
4+
idp_blacklist_file: /path/to/blacklist.json
45
sp_config:
56
key_file: backend.key
67
cert_file: backend.crt

src/satosa/backends/saml2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, outgoing, internal_attributes, config, base_url, name):
6363
self.discosrv = config.get(self.KEY_DISCO_SRV)
6464
self.encryption_keys = []
6565
self.outstanding_queries = {}
66+
self.idp_blacklist_file = config.get('idp_blacklist_file', None)
6667

6768
sp_keypairs = sp_config.getattr('encryption_keypairs', '')
6869
sp_key_file = sp_config.getattr('key_file', '')
@@ -149,6 +150,16 @@ def authn_request(self, context, entity_id):
149150
:param entity_id: Target IDP entity id
150151
:return: response to the user agent
151152
"""
153+
154+
# If IDP blacklisting is enabled and the selected IDP is blacklisted,
155+
# stop here
156+
if self.idp_blacklist_file:
157+
with open(self.idp_blacklist_file) as blacklist_file:
158+
blacklist_array = json.load(blacklist_file)['blacklist']
159+
if entity_id in blacklist_array:
160+
satosa_logging(logger, logging.DEBUG, "IdP with EntityID {} is blacklisted".format(entity_id), context.state, exc_info=False)
161+
raise SATOSAAuthenticationError(context.state, "Selected IdP is blacklisted for this backend")
162+
152163
kwargs = {}
153164
authn_context = self.construct_requested_authn_context(entity_id)
154165
if authn_context:

0 commit comments

Comments
 (0)