浏览代码

[core] Ignore case when searching or creating LDAP users

Romain Rigaux 10 年之前
父节点
当前提交
08e9868d4e

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

@@ -208,11 +208,11 @@
 
 
     # Ignore the case of usernames when searching for existing users.
     # Ignore the case of usernames when searching for existing users.
     # Only supported in remoteUserDjangoBackend.
     # Only supported in remoteUserDjangoBackend.
-    ## ignore_username_case=false
+    ## ignore_username_case=true
 
 
     # Ignore the case of usernames when searching for existing users to authenticate with.
     # Ignore the case of usernames when searching for existing users to authenticate with.
     # Only supported in remoteUserDjangoBackend.
     # Only supported in remoteUserDjangoBackend.
-    ## force_username_lowercase=false
+    ## force_username_lowercase=true
 
 
     # Users will expire after they have not logged in for 'n' amount of seconds.
     # Users will expire after they have not logged in for 'n' amount of seconds.
     # A negative number means that users will never expire.
     # A negative number means that users will never expire.

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

@@ -211,11 +211,11 @@
 
 
     # Ignore the case of usernames when searching for existing users.
     # Ignore the case of usernames when searching for existing users.
     # Only supported in remoteUserDjangoBackend.
     # Only supported in remoteUserDjangoBackend.
-    ## ignore_username_case=false
+    ## ignore_username_case=true
 
 
     # Ignore the case of usernames when searching for existing users to authenticate with.
     # Ignore the case of usernames when searching for existing users to authenticate with.
     # Only supported in remoteUserDjangoBackend.
     # Only supported in remoteUserDjangoBackend.
-    ## force_username_lowercase=false
+    ## force_username_lowercase=true
 
 
     # Users will expire after they have not logged in for 'n' amount of seconds.
     # Users will expire after they have not logged in for 'n' amount of seconds.
     # A negative number means that users will never expire.
     # A negative number means that users will never expire.

+ 10 - 6
desktop/core/src/desktop/auth/views_test.py

@@ -269,12 +269,12 @@ class TestRemoteUserLogin(object):
     response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "FOO4"})
     response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "FOO4"})
     assert_equal(200, response.status_code, "Expected ok status.")
     assert_equal(200, response.status_code, "Expected ok status.")
     assert_equal(2, len(User.objects.all()))
     assert_equal(2, len(User.objects.all()))
-    assert_equal('FOO4', User.objects.all()[1].username)
+    assert_equal('foo4', User.objects.all()[1].username)
 
 
     response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "foo4"})
     response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "foo4"})
     assert_equal(200, response.status_code, "Expected ok status.")
     assert_equal(200, response.status_code, "Expected ok status.")
     assert_equal(2, len(User.objects.all()))
     assert_equal(2, len(User.objects.all()))
-    assert_equal('FOO4', User.objects.all()[1].username)
+    assert_equal('foo4', User.objects.all()[1].username)
 
 
   def test_force_lower_case(self):
   def test_force_lower_case(self):
     self.reset.append( conf.AUTH.FORCE_USERNAME_LOWERCASE.set_for_testing(True) )
     self.reset.append( conf.AUTH.FORCE_USERNAME_LOWERCASE.set_for_testing(True) )
@@ -294,10 +294,14 @@ class TestRemoteUserLogin(object):
     assert_equal('foo3', User.objects.all()[0].username)
     assert_equal('foo3', User.objects.all()[0].username)
 
 
   def test_ignore_case_and_force_lower_case(self):
   def test_ignore_case_and_force_lower_case(self):
-    response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "FOO3"})
-    assert_equal(200, response.status_code, "Expected ok status.")
-    assert_equal(1, len(User.objects.all()))
-    assert_equal('FOO3', User.objects.all()[0].username)
+    reset = conf.AUTH.FORCE_USERNAME_LOWERCASE.set_for_testing(False)
+    try:
+      response = self.c.post('/accounts/login/', {}, **{"REMOTE_USER": "FOO3"})
+      assert_equal(200, response.status_code, "Expected ok status.")
+      assert_equal(1, len(User.objects.all()))
+      assert_equal('FOO3', User.objects.all()[0].username)
+    finally:
+      reset()
 
 
     self.reset.append( conf.AUTH.FORCE_USERNAME_LOWERCASE.set_for_testing(True) )
     self.reset.append( conf.AUTH.FORCE_USERNAME_LOWERCASE.set_for_testing(True) )
     self.reset.append( conf.AUTH.IGNORE_USERNAME_CASE.set_for_testing(True) )
     self.reset.append( conf.AUTH.IGNORE_USERNAME_CASE.set_for_testing(True) )

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

@@ -458,11 +458,11 @@ AUTH = ConfigSection(
     IGNORE_USERNAME_CASE = Config("ignore_username_case",
     IGNORE_USERNAME_CASE = Config("ignore_username_case",
                                   help=_("Ignore the case of usernames when searching for existing users in Hue."),
                                   help=_("Ignore the case of usernames when searching for existing users in Hue."),
                                   type=coerce_bool,
                                   type=coerce_bool,
-                                  default=False),
+                                  default=True),
     FORCE_USERNAME_LOWERCASE = Config("force_username_lowercase",
     FORCE_USERNAME_LOWERCASE = Config("force_username_lowercase",
                                       help=_("Force usernames to lowercase when creating new users from LDAP."),
                                       help=_("Force usernames to lowercase when creating new users from LDAP."),
                                       type=coerce_bool,
                                       type=coerce_bool,
-                                      default=False),
+                                      default=True),
     EXPIRES_AFTER = Config("expires_after",
     EXPIRES_AFTER = Config("expires_after",
                             help=_("Users will expire after they have not logged in for 'n' amount of seconds."
                             help=_("Users will expire after they have not logged in for 'n' amount of seconds."
                                    "A negative number means that users will never expire."),
                                    "A negative number means that users will never expire."),