Skip to content

Commit fdb6e9d

Browse files
Merge pull request #396 from shaardie/ldap_search_filter
Add option search_filter to ldap
2 parents 65a4619 + 52dce96 commit fdb6e9d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

example/plugins/microservices/ldap_attribute_store.yaml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ config:
8787

8888
ldap_identifier_attribute: uid
8989

90+
# Override the contructed search_filter with ldap_identifier_attribute
91+
# with an own filter. This allows more complex queries.
92+
# {0} will be injected with the ordered_identifier_candidates.
93+
# For example:
94+
# search_filter: "(&(uid={0})(isMemberOf=authorized))"
95+
search_filter: None
96+
9097
# Whether to clear values for attributes incoming
9198
# to this microservice. Default is no or false.
9299
clear_input_attributes: no

src/satosa/micro_services/ldap_attribute_store.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class LdapAttributeStore(ResponseMicroService):
4646
"clear_input_attributes": False,
4747
"ignore": False,
4848
"ldap_identifier_attribute": None,
49+
"search_filter": None,
4950
"ldap_url": None,
5051
"ldap_to_internal_map": None,
5152
"on_ldap_search_result_empty": None,
@@ -479,8 +480,11 @@ def process(self, context, data):
479480
logger.debug(logline)
480481

481482
for filter_val in filter_values:
482-
ldap_ident_attr = config["ldap_identifier_attribute"]
483-
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
483+
if config["search_filter"]:
484+
search_filter = config["search_filter"].format(filter_val)
485+
else:
486+
ldap_ident_attr = config["ldap_identifier_attribute"]
487+
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
484488
msg = {
485489
"message": "LDAP query with constructed search filter",
486490
"search filter": search_filter,

0 commit comments

Comments
 (0)