Quellcode durchsuchen

HUE-1009 [core] LDAP backend user creation configurable

abec vor 13 Jahren
Ursprung
Commit
4e00f7744c

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -133,6 +133,10 @@
   # For use when using LdapBackend for Hue authentication
   ## ldap_username_pattern="uid=<username>,ou=People,dc=mycompany,dc=com"
 
+  # Create users in Hue when they try to login with their LDAP credentials
+  # For use when using LdapBackend for Hue authentication
+  ## create_users_on_login = true
+
       [[[users]]]
 
       # Base filter for searching for users

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -142,6 +142,10 @@
   # For use when using LdapBackend for Hue authentication
   ## ldap_username_pattern="uid=<username>,ou=People,dc=mycompany,dc=com"
 
+  # Create users in Hue when they try to login with their LDAP credentials
+  # For use when using LdapBackend for Hue authentication
+  ## create_users_on_login = true
+
       [[[users]]]
 
       # Base filter for searching for users

+ 2 - 1
desktop/core/src/desktop/auth/backend.py

@@ -276,6 +276,8 @@ class LdapBackend(object):
       existing_profile = get_profile(existing_user)
       if existing_profile.creation_method == str(UserProfile.CreationMethod.EXTERNAL):
         is_super = User.objects.get(username=username).is_superuser
+    elif not desktop.conf.LDAP.CREATE_USERS_ON_LOGIN.get():
+      return None
 
     try:
       user = self._backend.authenticate(username, password)
@@ -309,7 +311,6 @@ class LdapBackend(object):
     return True
 
 
-
 class SpnegoDjangoBackend(django.contrib.auth.backends.ModelBackend):
   """
   A note about configuration:

+ 4 - 0
desktop/core/src/desktop/conf.py

@@ -309,6 +309,10 @@ LDAP = ConfigSection(
     BIND_PASSWORD=Config("bind_password",
                    default=None,
                    help=_("The password for the bind user.")),
+    CREATE_USERS_ON_LOGIN = Config("create_users_on_login",
+      help=_("Create users when they login with their LDAP credentials."),
+      type=coerce_bool,
+      default=True),
 
     USERS = ConfigSection(
       key="users",