Repository: hive
Updated Branches:
  refs/heads/master a8ef2147f -> 07016c5ee


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/07016c5e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/07016c5e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/07016c5e

Branch: refs/heads/master
Commit: 07016c5eecd909a6719f6e16c6efbbc19f3f9053
Parents: a8ef214
Author: Daniel Dai <dai...@gmail.com>
Authored: Fri Aug 3 15:44:45 2018 -0700
Committer: Daniel Dai <dai...@gmail.com>
Committed: Mon Aug 6 23:03:25 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/07016c5e/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

Reply via email to