瀏覽代碼

[core] By default ignore case of usernames with LDAP

Romain Rigaux 10 年之前
父節點
當前提交
2ae370d

+ 4 - 4
apps/useradmin/src/useradmin/test_ldap.py

@@ -465,14 +465,14 @@ def test_useradmin_ldap_user_integration():
     # Test lower case
     User.objects.filter(username__iexact='Rock').delete()
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)
-    assert_true(User.objects.filter(username='Rock').exists())
-    assert_false(User.objects.filter(username='rock').exists())
+    assert_false(User.objects.filter(username='Rock').exists())
+    assert_true(User.objects.filter(username='rock').exists())
 
     done.append(desktop.conf.LDAP.FORCE_USERNAME_LOWERCASE.set_for_testing(True))
 
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)
-    assert_true(User.objects.filter(username='Rock').exists())
-    assert_false(User.objects.filter(username='rock').exists())
+    assert_false(User.objects.filter(username='Rock').exists())
+    assert_true(User.objects.filter(username='rock').exists())
 
     User.objects.filter(username='Rock').delete()
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)

+ 4 - 4
apps/useradmin/src/useradmin/test_ldap_deprecated.py

@@ -427,14 +427,14 @@ def test_useradmin_ldap_user_integration():
     # Test lower case
     User.objects.filter(username__iexact='Rock').delete()
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)
-    assert_true(User.objects.filter(username='Rock').exists())
-    assert_false(User.objects.filter(username='rock').exists())
+    assert_false(User.objects.filter(username='Rock').exists())
+    assert_true(User.objects.filter(username='rock').exists())
 
     done.append(desktop.conf.LDAP.FORCE_USERNAME_LOWERCASE.set_for_testing(True))
 
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)
-    assert_true(User.objects.filter(username='Rock').exists())
-    assert_false(User.objects.filter(username='rock').exists())
+    assert_false(User.objects.filter(username='Rock').exists())
+    assert_true(User.objects.filter(username='rock').exists())
 
     User.objects.filter(username='Rock').delete()
     import_ldap_users(ldap_access.CACHED_LDAP_CONN, 'Rock', sync_groups=False, import_by_dn=False)

+ 2 - 2
desktop/conf.dist/hue.ini

@@ -273,10 +273,10 @@
     ## sync_groups_on_login=false
 
     # Ignore the case of usernames when searching for existing users in Hue.
-    ## ignore_username_case=false
+    ## ignore_username_case=true
 
     # Force usernames to lowercase when creating new users from LDAP.
-    ## force_username_lowercase=false
+    ## force_username_lowercase=true
 
     # Use search bind authentication.
     ## search_bind_authentication=true

+ 2 - 2
desktop/conf/pseudo-distributed.ini.tmpl

@@ -280,10 +280,10 @@
     ## sync_groups_on_login=false
 
     # Ignore the case of usernames when searching for existing users in Hue.
-    ## ignore_username_case=false
+    ## ignore_username_case=true
 
     # Force usernames to lowercase when creating new users from LDAP.
-    ## force_username_lowercase=false
+    ## force_username_lowercase=true
 
     # Use search bind authentication.
     ## search_bind_authentication=true

+ 2 - 2
desktop/core/src/desktop/auth/views_test.py

@@ -151,7 +151,7 @@ class TestLdapLogin(PseudoHdfsTestBase):
     })
     assert_equal(302, response.status_code, "Expected ok redirect status.")
     assert_equal(1, len(User.objects.all()))
-    assert_equal('LDAP1', User.objects.all()[0].username)
+    assert_equal('ldap1', User.objects.all()[0].username)
 
     self.c.logout()
 
@@ -161,7 +161,7 @@ class TestLdapLogin(PseudoHdfsTestBase):
     })
     assert_equal(302, response.status_code, "Expected ok redirect status.")
     assert_equal(1, len(User.objects.all()))
-    assert_equal('LDAP1', User.objects.all()[0].username)
+    assert_equal('ldap1', User.objects.all()[0].username)
 
   def test_login_force_lower_case(self):
     self.reset.append(conf.LDAP.FORCE_USERNAME_LOWERCASE.set_for_testing(True))

+ 2 - 3
desktop/core/src/desktop/conf.py

@@ -542,12 +542,11 @@ LDAP = ConfigSection(
     IGNORE_USERNAME_CASE = Config("ignore_username_case",
       help=_("Ignore the case of usernames when searching for existing users in Hue."),
       type=coerce_bool,
-      default=False),
+      default=True),
     FORCE_USERNAME_LOWERCASE = Config("force_username_lowercase",
       help=_("Force usernames to lowercase when creating new users from LDAP."),
       type=coerce_bool,
-      private=True,
-      default=False),
+      default=True),
     SUBGROUPS = Config("subgroups",
       help=_("Choose which kind of subgrouping to use: nested or suboordinate (deprecated)."),
       type=coerce_str_lowercase,