Skip to content

Commit

Permalink
Ensure allowed_groups is configured along with group_search_filter etc
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Sep 23, 2024
1 parent b45f2ed commit 7d62e1c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ldapauthenticator/ldapauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def _require_either_lookup_dn_or_bind_dn_template(self, change):
help="List of attributes to be searched",
)

@observe("allowed_groups", "group_search_filter", "group_attributes")
def _ensure_allowed_groups_requirements(self, change):
if not self.allowed_groups:
return
if not self.group_search_filter or not self.group_attributes:
raise ValueError(
"LDAPAuthenticator.allowed_groups requires both "
"group_search_filter and group_attributes to be configured"
)

valid_username_regex = Unicode(
r"^[a-z][.a-z0-9_-]*$",
config=True,
Expand Down Expand Up @@ -607,11 +617,6 @@ async def authenticate(self, handler, data):

ldap_groups = []
if self.allowed_groups:
if not self.group_search_filter or not self.group_attributes:
self.log.warning(
"Missing group_search_filter or group_attributes. Both are required."
)
return None
self.log.debug("username:%s Using dn %s", resolved_username, userdn)
for group in self.allowed_groups:
found = conn.search(
Expand Down

0 comments on commit 7d62e1c

Please sign in to comment.