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

Fix to LDAP RO group validation and CLI credentials quoting #1405

Merged
merged 2 commits into from
Nov 4, 2024
Merged
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
4 changes: 2 additions & 2 deletions nipap-cli/nipap_cli/nipap_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def setup_connection():
con_params['password'] = getpass.getpass()

# Quote username & password
con_params['username'] = quote(con_params['username'])
con_params['password'] = quote(con_params['password'])
con_params['username'] = quote(con_params['username'], safe="")
con_params['password'] = quote(con_params['password'], safe="")

# build XML-RPC URI
pynipap.xmlrpc_uri = "%(protocol)s://%(username)s:%(password)s@%(hostname)s:%(port)s" % con_params
Expand Down
4 changes: 3 additions & 1 deletion nipap/nipap/authlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ def authenticate(self):
['cn', 'memberOf'],
)

self._logger.debug("User %s is member of groups: %s", self.username, res[0][1].get('memberOf', []))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (111 > 79 characters)


# Data received from LDAP is bytes, make sure to decode/encode
# accordingly before using it
if res[0][1]['cn'][0] is not None:
Expand All @@ -569,7 +571,7 @@ def authenticate(self):
# if ro_group is configured, and the user is a member of
# neither the ro_group nor the rw_group, fail authentication.
if self._ldap_ro_group:
if self._ldap_ro_group not in res[0][1].get('memberOf', []):
if self._ldap_ro_group.encode('utf-8') not in res[0][1].get('memberOf', []):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (100 > 79 characters)

self._authenticated = False
return self._authenticated
else:
Expand Down
Loading