ソースを参照

HUE-8821 [core] Fix Hue LDAP StartTLS implementation

Prakash Ranade 6 年 前
コミット
4ad2d021c6

+ 2 - 0
apps/useradmin/src/useradmin/ldap_access.py

@@ -157,6 +157,8 @@ class LdapConnection(object):
       ldap.set_option(ldap.OPT_DEBUG_LEVEL, ldap_config.DEBUG_LEVEL.get())
 
     self.ldap_handle = ldap.initialize(uri=ldap_url, trace_level=ldap_config.TRACE_LEVEL.get())
+    if self.ldap_config.USE_START_TLS.get():
+      self.ldap_handle.start_tls_s()
 
     if bind_user:
       try:

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

@@ -434,12 +434,11 @@ class LdapBackend(object):
         setattr(self._backend.settings, 'USER_DN_TEMPLATE', "%(user)s@" + nt_domain)
 
     # Certificate-related config settings
+    setattr(self._backend.settings, 'START_TLS', ldap_config.USE_START_TLS.get())
     if ldap_config.LDAP_CERT.get():
-      setattr(self._backend.settings, 'START_TLS', ldap_config.USE_START_TLS.get())
       ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
       ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, ldap_config.LDAP_CERT.get())
     else:
-      setattr(self._backend.settings, 'START_TLS', False)
       ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
 
     if ldap_config.FOLLOW_REFERRALS.get():