Skip to content

Commit f0c57fd

Browse files
committed
Select LDAP config by extracted attribute
This patch introduces a new global config variable `provider_attribute` to make it possible to select the config not only by entity but also select the config variable by a previous set attribute. This way it is possible to use a single point of authentication, but enrich the information from different ldap server based on e.g. the domain attribute extracted in previous steps.
1 parent 43fd132 commit f0c57fd

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
@@ -97,13 +97,23 @@ config:
9797
# from LDAP. The default is not to redirect.
9898
on_ldap_search_result_empty: https://my.vo.org/please/go/enroll
9999

100-
# The microservice may be configured per entityID.
100+
# The microservice may be configured per entityID or per extracted attribute.
101101
# 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
102+
# the authenticating IdP, the entityID of the CO virtual IdP, or the
103+
# extracted attribute defined by `global.provider_attribute`.
104+
# When more than one configured key matches during a flow
105+
# the priority ordering is provider attribute, requesting SP, then authenticating IdP, then
105106
# CO virtual IdP. Αny missing parameters are taken from the
106107
# default configuration.
108+
global:
109+
provider_attribute: domain
110+
111+
# domain attribute is extracted in a previous microserver and used as a key
112+
# here.
113+
company.com:
114+
ldap_url: ldaps://ldap.company.com
115+
search_base: ou=group,dc=identity,dc=company,dc=com
116+
107117
https://sp.myserver.edu/shibboleth-sp:
108118
search_base: ou=People,o=MyVO,dc=example,dc=org
109119
search_return_attributes:
@@ -120,3 +130,4 @@ config:
120130
# The microservice may be configured to ignore a particular entityID.
121131
https://another.sp.myserver.edu:
122132
ignore: true
133+

src/satosa/micro_services/ldap_attribute_store.py

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

8282
self.config = {}
8383

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

8894
connections = {}
8995

@@ -412,6 +418,14 @@ def process(self, context, data):
412418
co_entity_id = state.get(frontend_name, {}).get(co_entity_id_key)
413419

414420
entity_ids = [requester, issuer, co_entity_id, "default"]
421+
if self.provider_attribute:
422+
try:
423+
entity_ids.insert(
424+
0,
425+
data.attributes[self.provider_attribute][0]
426+
)
427+
except (KeyError, IndexError):
428+
pass
415429

416430
config, entity_id = next((self.config.get(e), e)
417431
for e in entity_ids if self.config.get(e))

0 commit comments

Comments
 (0)