You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2018/08/03 22:44:23 UTC

hive git commit: HIVE-20118: SessionStateUserAuthenticator.getGroupNames() is always empty (Daniel Dai, reviewed by Thejas Nair)

Repository: hive
Updated Branches:
  refs/heads/branch-3 c8d5ae689 -> 9f9b1e9b2


HIVE-20118: SessionStateUserAuthenticator.getGroupNames() is always empty (Daniel Dai, reviewed by Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/9f9b1e9b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/9f9b1e9b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/9f9b1e9b

Branch: refs/heads/branch-3
Commit: 9f9b1e9b283dd9e186805c2c4b920e920d4e560d
Parents: c8d5ae6
Author: Daniel Dai <da...@gmail.com>
Authored: Fri Aug 3 15:44:11 2018 -0700
Committer: Daniel Dai <da...@gmail.com>
Committed: Fri Aug 3 15:44:11 2018 -0700

----------------------------------------------------------------------
 .../hive/ql/security/SessionStateUserAuthenticator.java       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/9f9b1e9b/ql/src/java/org/apache/hadoop/hive/ql/security/SessionStateUserAuthenticator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/SessionStateUserAuthenticator.java b/ql/src/java/org/apache/hadoop/hive/ql/security/SessionStateUserAuthenticator.java
index 3bf990a..1ded295 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/SessionStateUserAuthenticator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/SessionStateUserAuthenticator.java
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.security.UserGroupInformation;
 
 /**
  * Authenticator that returns the userName set in SessionState. For use when authorizing with HS2
@@ -35,10 +36,14 @@ public class SessionStateUserAuthenticator implements HiveAuthenticationProvider
 
   protected Configuration conf;
   private SessionState sessionState;
+  private List<String> groups;
 
   @Override
   public List<String> getGroupNames() {
-    return groupNames;
+    if (groups == null) {
+      groups = UserGroupInformation.createRemoteUser(sessionState.getUserName()).getGroups();
+    }
+    return groups;
   }
 
   @Override