Skip to content

Commit

Permalink
LDAP auth: do not blindly assume groups have a 2-letter naming attribute
Browse files Browse the repository at this point in the history
Instead, strip away everything before (and including) the '=' sign of ther RDN.
  • Loading branch information
marschap committed Jan 2, 2025
1 parent 8c2feb4 commit 0253682
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions radicale/auth/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def _login2(self, login: str, password: str) -> str:
if self._ldap_load_groups:
tmp = []
for g in user_entry[1]['memberOf']:
tmp.append(g.decode('utf-8').split(',')[0][3:])
"""Get group g's RDN's attribute value"""
g = g.decode('utf-8').split(',')[0]
tmp.append(g.partition('=')[2])
self._ldap_groups = set(tmp)
logger.debug("_login2 LDAP groups of user: %s", ",".join(self._ldap_groups))
conn.unbind()
Expand Down Expand Up @@ -205,7 +207,9 @@ def _login3(self, login: str, password: str) -> str:
if self._ldap_load_groups:
tmp = []
for g in user_entry['attributes']['memberOf']:
tmp.append(g.split(',')[0][3:])
"""Get group g's RDN's attribute value"""
g = g.split(',')[0]
tmp.append(g.partition('=')[2])
self._ldap_groups = set(tmp)
logger.debug("_login3 LDAP groups of user: %s", ",".join(self._ldap_groups))
conn.unbind()
Expand Down

0 comments on commit 0253682

Please sign in to comment.