Skip to content

Commit ab079b9

Browse files
author
Ioannis Kakavas
committed
Enable idp blacklisting for SAML backends
1 parent a7d3dff commit ab079b9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

example/plugins/backends/saml2_backend.yaml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ config:
1313
local: [idp.xml]
1414

1515
entityid: <base_url>/<name>/proxy_saml2_backend.xml
16+
idp_blacklist_enabled: true
17+
idp_blacklist_file: /path/to/blacklist.json
1618
service:
1719
sp:
1820
want_response_signed: true

src/satosa/backends/saml2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ def authn_request(self, context, entity_id):
149149
:param entity_id: Target IDP entity id
150150
:return: response to the user agent
151151
"""
152+
153+
# If IDP blacklisting is enabled and the selected IDP is blacklisted,
154+
# stop here
155+
if self.config["sp_config"]["idp_blacklist_enabled"]:
156+
with open(self.config["sp_config"]["idp_blacklist_file"]) as blacklist_file:
157+
blacklist_array = json.load(blacklist_file)['blacklist']
158+
if entity_id in blacklist_array:
159+
satosa_logging(logger, logging.DEBUG, "IdP with EntityID {} is blacklisted".format(entity_id), context.state,
160+
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)