Skip to content

Commit abcf1d5

Browse files
committed
[AIRFLOW-1711] Use ldap3 dict for group membership
Certain schemas for group membership return a string instead of a list. Instead of using a check we now use the entries API from ldap3. Closes apache#2731 from bolkedebruin/AIRFLOW-1711
1 parent 574e1c6 commit abcf1d5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

airflow/contrib/auth/backends/ldap_auth.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,10 @@ def group_contains_user(conn, search_base, group_filter, user_name_attr, usernam
7676
attributes=[native(user_name_attr)]):
7777
log.warning("Unable to find group for %s %s", search_base, search_filter)
7878
else:
79-
for resp in conn.response:
80-
if (
81-
'attributes' in resp and (
82-
resp['attributes'].get(user_name_attr)[0] == username or
83-
resp['attributes'].get(user_name_attr) == username
84-
)
85-
):
79+
for entry in conn.entries:
80+
if username in getattr(entry, user_name_attr).values:
8681
return True
82+
8783
return False
8884

8985

0 commit comments

Comments
 (0)