Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option search_filter to ldap #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ config:

ldap_identifier_attribute: uid

# Override the contructed search_filter with ldap_identifier_attribute
# with an own filter. This allows more complex queries.
# {0} will be injected with the ordered_identifier_candidates.
# For example:
# search_filter: "(&(uid={0})(isMemberOf=authorized))"
search_filter: None

# Whether to clear values for attributes incoming
# to this microservice. Default is no or false.
clear_input_attributes: no
Expand Down
8 changes: 6 additions & 2 deletions src/satosa/micro_services/ldap_attribute_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class LdapAttributeStore(ResponseMicroService):
"clear_input_attributes": False,
"ignore": False,
"ldap_identifier_attribute": None,
"search_filter": None,
"ldap_url": None,
"ldap_to_internal_map": None,
"on_ldap_search_result_empty": None,
Expand Down Expand Up @@ -473,8 +474,11 @@ def process(self, context, data):
logger.debug(logline)

for filter_val in filter_values:
ldap_ident_attr = config["ldap_identifier_attribute"]
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
if config["search_filter"]:
search_filter = config["search_filter"].format(filter_val)
else:
ldap_ident_attr = config["ldap_identifier_attribute"]
search_filter = "({0}={1})".format(ldap_ident_attr, filter_val)
msg = {
"message": "LDAP query with constructed search filter",
"search filter": search_filter,
Expand Down