You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by sa...@apache.org on 2018/04/25 21:08:25 UTC

incubator-airflow git commit: [AIRFLOW-1781] Make search case-insensitive in LDAP group

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 8e8c4eb4d -> ec0d227ef


[AIRFLOW-1781] Make search case-insensitive in LDAP group

Closes #2750 from patsak/f/ldap_search


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/ec0d227e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/ec0d227e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/ec0d227e

Branch: refs/heads/master
Commit: ec0d227ef8bc02f63515e7cb011f15d8fcf7730b
Parents: 8e8c4eb
Author: k.privezentsev <ko...@kaspersky.com>
Authored: Wed Apr 25 14:07:30 2018 -0700
Committer: r39132 <si...@yahoo.com>
Committed: Wed Apr 25 14:07:53 2018 -0700

----------------------------------------------------------------------
 airflow/contrib/auth/backends/ldap_auth.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/ec0d227e/airflow/contrib/auth/backends/ldap_auth.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/auth/backends/ldap_auth.py b/airflow/contrib/auth/backends/ldap_auth.py
index c887ffb..1ab5fcd 100644
--- a/airflow/contrib/auth/backends/ldap_auth.py
+++ b/airflow/contrib/auth/backends/ldap_auth.py
@@ -77,12 +77,13 @@ def get_ldap_connection(dn=None, password=None):
 
 def group_contains_user(conn, search_base, group_filter, user_name_attr, username):
     search_filter = '(&({0}))'.format(group_filter)
+
     if not conn.search(native(search_base), native(search_filter),
                        attributes=[native(user_name_attr)]):
         log.warning("Unable to find group for %s %s", search_base, search_filter)
     else:
         for entry in conn.entries:
-            if username in getattr(entry, user_name_attr).values:
+            if username.lower() in map(lambda attr: attr.lower(), getattr(entry, user_name_attr).values):
                 return True
 
     return False