Skip to content

Commit d244ffe

Browse files
committed
Generalize per-SP override for LDAP attribute authority
Generalize the per-SP override for the LDAP attribute authority microservice so that the override can be per-SP, per-IdP, or per- CO virtual IdP. This enhancement does not allow for nested overrides, which may be included in future work.
1 parent 23df299 commit d244ffe

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

example/plugins/microservices/ldap_attribute_store.yaml.example

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ module: LdapAttributeStore
22
name: LdapAttributeStore
33
config:
44

5-
# The microservice may be configured per SP.
6-
# The configuration key is the entityID of the SP.
7-
# The empty key ("") specifies the default configuration
8-
"":
5+
# The microservice may be configured per entityID.
6+
# The configuration key is the entityID of the requesting SP,
7+
# the authenticating IdP, or the entityID of the CO virtual IdP.
8+
# The key "default" specifies the default configuration
9+
default:
910
ldap_url: ldaps://ldap.example.org
1011
bind_dn: cn=admin,dc=example,dc=org
1112
# Obtain bind password from environment variable LDAP_BIND_PASSWORD.
@@ -96,9 +97,13 @@ config:
9697
# from LDAP. The default is not to redirect.
9798
on_ldap_search_result_empty: https://my.vo.org/please/go/enroll
9899

99-
# The microservice may be configured per SP.
100-
# The configuration key is the entityID of the SP.
101-
# Αny missing parameters are looked up from the default configuration.
100+
# The microservice may be configured per entityID.
101+
# The configuration key is the entityID of the requesting SP,
102+
# the authenticating IdP, or the entityID of the CO virtual IdP.
103+
# When more than one configured entityID matches during a flow
104+
# the priority ordering is requesting SP, then authenticating IdP, then
105+
# CO virtual IdP. Αny missing parameters are taken from the
106+
# default configuration.
102107
https://sp.myserver.edu/shibboleth-sp:
103108
search_base: ou=People,o=MyVO,dc=example,dc=org
104109
search_return_attributes:
@@ -109,6 +114,9 @@ config:
109114
user_id_from_attrs:
110115
- uid
111116

112-
# The microservice may be configured to ignore a particular SP.
117+
https://federation-proxy.my.edu/satosa/idp/proxy/some_co
118+
search_base: ou=People,o=some_co,dc=example,dc=org
119+
120+
# The microservice may be configured to ignore a particular entityID.
113121
https://another.sp.myserver.edu:
114122
ignore: true

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from satosa.exception import SATOSAError
1919
from satosa.micro_services.base import ResponseMicroService
2020
from satosa.response import Redirect
21+
from satosa.frontends.saml2 import SAMLVirtualCoFrontend
22+
from satosa.routing import STATE_KEY as ROUTING_STATE_KEY
2123

2224

2325
logger = logging.getLogger(__name__)
@@ -399,23 +401,35 @@ def process(self, context, data):
399401
Default interface for microservices. Process the input data for
400402
the input context.
401403
"""
402-
session_id = lu.get_session_id(context.state)
404+
state = context.state
405+
session_id = lu.get_session_id(state)
403406

404-
issuer = data.auth_info.issuer
405407
requester = data.requester
406-
config = self.config.get(requester) or self.config["default"]
408+
issuer = data.auth_info.issuer
409+
410+
frontend_name = state.get(ROUTING_STATE_KEY)
411+
co_entity_id_key = SAMLVirtualCoFrontend.KEY_CO_ENTITY_ID
412+
co_entity_id = state.get(frontend_name, {}).get(co_entity_id_key)
413+
414+
entity_ids = [requester, issuer, co_entity_id, "default"]
415+
416+
config, entity_id = next((self.config.get(e), e)
417+
for e in entity_ids if self.config.get(e))
418+
407419
msg = {
408420
"message": "entityID for the involved entities",
409421
"requester": requester,
410422
"issuer": issuer,
411423
"config": self._filter_config(config),
412424
}
425+
if co_entity_id:
426+
msg["co_entity_id"] = co_entity_id
413427
logline = lu.LOG_FMT.format(id=session_id, message=msg)
414428
logger.debug(logline)
415429

416-
# Ignore this SP entirely if so configured.
430+
# Ignore this entityID entirely if so configured.
417431
if config["ignore"]:
418-
msg = "Ignoring SP {}".format(requester)
432+
msg = "Ignoring entityID {}".format(entity_id)
419433
logline = lu.LOG_FMT.format(id=session_id, message=msg)
420434
logger.info(logline)
421435
return super().process(context, data)

0 commit comments

Comments
 (0)