浏览代码

[beeswax] Update impersonation settings

If SASL, its gets the real username through the protocol and not from the username
of the session.
In case if impersonation, the username of the proxy user needs to be hue and
the proxied username needs to be added as a configuration parameter.
Romain Rigaux 12 年之前
父节点
当前提交
ef9bc19d65
共有 2 个文件被更改,包括 6 次插入8 次删除
  1. 1 1
      apps/beeswax/src/beeswax/hive_site.py
  2. 5 7
      apps/beeswax/src/beeswax/server/hive_server2_lib.py

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

@@ -37,7 +37,7 @@ _METASTORE_LOC_CACHE = None
 
 _CNF_HIVESERVER2_KERBEROS_PRINCIPAL = 'hive.server2.authentication.kerberos.principal'
 _CNF_HIVESERVER2_AUTHENTICATION = 'hive.server2.authentication'
-_CNF_HIVESERVER2_IMPERSONATION = 'hive.server2.enable.impersonation'
+_CNF_HIVESERVER2_IMPERSONATION = 'hive.server2.enable.doAs'
 
 # Host is whatever up to the colon. Allow and ignore a trailing slash.
 _THRIFT_URI_RE = re.compile("^thrift://([^:]+):(\d+)[/]?$")

+ 5 - 7
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -339,19 +339,17 @@ class HiveServerClient:
 
   def open_session(self, user):
     kwargs = {
-        'username': user.username,
+        'username': user.username, # If SASL, it gets the username from the authentication mechanism" since it dependents on it.
         'configuration': {},
     }
 
-    if self.use_sasl:
-      # HS2 PLAIN still requires a non null username but None works
-      kwargs.update({'username': self.kerberos_principal_short_name})
-
     if self.impersonation_enabled:
+      kwargs.update({'username': 'hue'})
+
       if self.query_server['server_name'] == 'impala':
-        kwargs.update({'configuration': {'impala.doas.user': user.username}})
+        kwargs['configuration'].update({'impala.doas.user': user.username})
       else:
-        kwargs.update({'configuration': {'hive.server2.proxy.user': user.username}})
+        kwargs['configuration'].update({'hive.server2.proxy.user': user.username})
 
     req = TOpenSessionReq(**kwargs)
     res = self._client.OpenSession(req)