Преглед на файлове

HUE-9008 [hive] Add service when using thrift over http

Jean-Francois Desjeans Gauthier преди 6 години
родител
ревизия
02b86dd45b

+ 3 - 1
apps/beeswax/src/beeswax/hive_site.py

@@ -28,7 +28,7 @@ import socket
 
 from desktop.lib import security_util
 from hadoop import confparse
-from hadoop.ssl_client_site import get_trustore_location
+from hadoop.ssl_client_site import get_trustore_location, get_trustore_password
 
 import beeswax.conf
 
@@ -155,6 +155,8 @@ def hiveserver2_jdbc_url():
 
     if get_conf().get(_CNF_HIVESERVER2_TRUSTSTORE_PASSWORD):
       urlbase += ';trustStorePassword=%s' % get_conf().get(_CNF_HIVESERVER2_TRUSTSTORE_PASSWORD)
+    elif get_trustore_password():
+      urlbase += ';trustStorePassword=%s' % get_trustore_password()
 
   if is_transport_mode_http:
     urlbase += ';transportMode=http'

+ 5 - 5
desktop/core/src/desktop/lib/rest/http_client.py

@@ -123,17 +123,17 @@ class HttpClient(object):
     short_url = '%(scheme)s://%(netloc)s' % {'scheme': parsed_uri.scheme, 'netloc': parsed_uri.netloc}
     return short_url
 
-  def set_kerberos_auth(self):
+  def set_kerberos_auth(self, service="HTTP"):
     """Set up kerberos auth for the client, based on the current ticket."""
     mutual_auth = conf.KERBEROS.MUTUAL_AUTHENTICATION.get().upper()
     if mutual_auth == 'OPTIONAL':
-      self._session.auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL)
+      self._session.auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL, service=service)
     elif mutual_auth == 'REQUIRED':
-      self._session.auth = HTTPKerberosAuth(mutual_authentication=REQUIRED)
+      self._session.auth = HTTPKerberosAuth(mutual_authentication=REQUIRED, service=service)
     elif mutual_auth == 'DISABLED':
-      self._session.auth = HTTPKerberosAuth(mutual_authentication=DISABLED)
+      self._session.auth = HTTPKerberosAuth(mutual_authentication=DISABLED, service=service)
     else:
-      self._session.auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL)
+      self._session.auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL, service=service)
     return self
 
   def set_basic_auth(self, username, password):

+ 2 - 2
desktop/core/src/desktop/lib/thrift_/http_client.py

@@ -55,8 +55,8 @@ class THttpClient(TTransportBase):
   def open(self):
     pass
 
-  def set_kerberos_auth(self):
-    self._client.set_kerberos_auth()
+  def set_kerberos_auth(self, service="HTTP"):
+    self._client.set_kerberos_auth(service=service)
 
   def set_basic_auth(self, username, password):
     self._client.set_basic_auth(username, password)

+ 1 - 1
desktop/core/src/desktop/lib/thrift_util.py

@@ -317,7 +317,7 @@ def connect_to_thrift(conf):
 
   if conf.transport_mode == 'http':
     if conf.use_sasl and conf.mechanism != 'PLAIN':
-      mode.set_kerberos_auth()
+      mode.set_kerberos_auth(service=conf.kerberos_principal)
     else:
       mode.set_basic_auth(conf.username, conf.password)
 

+ 5 - 0
desktop/libs/hadoop/src/hadoop/ssl_client_site.py

@@ -28,6 +28,7 @@ _SSL_SITE_PATH = None                  # Path to ssl-client.xml
 _SSL_SITE_DICT = None                  # A dictionary of name/value config options
 
 _CNF_TRUSTORE_LOCATION = 'ssl.client.truststore.location'
+_CNF_TRUSTORE_PASSWORD = 'ssl.client.truststore.password'
 
 LOG = logging.getLogger(__name__)
 
@@ -66,3 +67,7 @@ def _parse_ssl_client_site():
 
 def get_trustore_location():
   return get_conf().get(_CNF_TRUSTORE_LOCATION)
+
+
+def get_trustore_password():
+  return get_conf().get(_CNF_TRUSTORE_PASSWORD)