Skip to content

Commit 4da0823

Browse files
Merge pull request #397 from shaardie/ldap_provider_attribute
Select LDAP config by extracted attribute
2 parents fdb6e9d + f0c57fd commit 4da0823

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

example/plugins/microservices/ldap_attribute_store.yaml.example

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,23 @@ config:
107107
# from LDAP. The default is not to redirect.
108108
on_ldap_search_result_empty: https://my.vo.org/please/go/enroll
109109

110-
# The microservice may be configured per entityID.
110+
# The microservice may be configured per entityID or per extracted attribute.
111111
# The configuration key is the entityID of the requesting SP,
112-
# the authenticating IdP, or the entityID of the CO virtual IdP.
113-
# When more than one configured entityID matches during a flow
114-
# the priority ordering is requesting SP, then authenticating IdP, then
112+
# the authenticating IdP, the entityID of the CO virtual IdP, or the
113+
# extracted attribute defined by `global.provider_attribute`.
114+
# When more than one configured key matches during a flow
115+
# the priority ordering is provider attribute, requesting SP, then authenticating IdP, then
115116
# CO virtual IdP. Αny missing parameters are taken from the
116117
# default configuration.
118+
global:
119+
provider_attribute: domain
120+
121+
# domain attribute is extracted in a previous microserver and used as a key
122+
# here.
123+
company.com:
124+
ldap_url: ldaps://ldap.company.com
125+
search_base: ou=group,dc=identity,dc=company,dc=com
126+
117127
https://sp.myserver.edu/shibboleth-sp:
118128
search_base: ou=People,o=MyVO,dc=example,dc=org
119129
search_return_attributes:
@@ -130,3 +140,4 @@ config:
130140
# The microservice may be configured to ignore a particular entityID.
131141
https://another.sp.myserver.edu:
132142
ignore: true
143+

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ def __init__(self, config, *args, **kwargs):
8383

8484
self.config = {}
8585

86+
# Get provider attribute
87+
self.provider_attribute = None
88+
if "global" in config:
89+
if "provider_attribute" in config["global"]:
90+
self.provider_attribute = config["global"]["provider_attribute"]
91+
8692
# Process the default configuration first then any per-SP overrides.
8793
sp_list = ["default"]
88-
sp_list.extend([key for key in config.keys() if key != "default"])
94+
sp_list.extend([key for key in config.keys() if key != "default" and key != "global"])
8995

9096
connections = {}
9197

@@ -419,6 +425,14 @@ def process(self, context, data):
419425
co_entity_id = state.get(frontend_name, {}).get(co_entity_id_key)
420426

421427
entity_ids = [requester, issuer, co_entity_id, "default"]
428+
if self.provider_attribute:
429+
try:
430+
entity_ids.insert(
431+
0,
432+
data.attributes[self.provider_attribute][0]
433+
)
434+
except (KeyError, IndexError):
435+
pass
422436

423437
config, entity_id = next((self.config.get(e), e)
424438
for e in entity_ids if self.config.get(e))

0 commit comments

Comments
 (0)