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

Feature: Allow matching group RDN (Relative Distinguished Name) in group_dns opt #115

Merged
merged 12 commits into from
Oct 24, 2024
Prev Previous commit
Next Next commit
fmt some log lines
  • Loading branch information
cognifloyd committed Oct 24, 2024
commit d468a9f874768387e2c924ed433e04049d799c34
17 changes: 10 additions & 7 deletions st2auth_ldap/ldap_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,11 @@ def _verify_user_group_membership(self, username, required_groups, user_groups,
additional_msg = ('user needs to be member of one or more of the following groups "%s" '
'for authentication to succeeed')

additional_msg = additional_msg % (str(list(required_groups)))
additional_msg = additional_msg % (str(list(sorted(required_groups))))

LOG.debug('Verifying user group membership using "%s" behavior (%s)' %
(check_behavior, additional_msg))
LOG.debug(
f'Verifying user group membership using "{check_behavior}" behavior ({additional_msg})'
)

# simple fully qualified DN match
if (
Expand All @@ -409,10 +410,12 @@ def _verify_user_group_membership(self, username, required_groups, user_groups,
):
return True

msg = ('Unable to verify membership for user "%s (required_groups=%s,'
'actual_groups=%s,check_behavior=%s)".' % (username, str(required_groups),
str(user_groups), check_behavior))
LOG.exception(msg)
LOG.exception(
f'Unable to verify membership for user "{username" '
f"(required_groups={list(sorted(required_groups))},"
f"actual_groups={list(sorted(norm_user_groups))},"
f"check_behavior={check_behavior})"
)

# Final safe guard
return False
Expand Down