AngersZhuuuu commented on a change in pull request #25179: [SPARK-28419][SQL] A 
patch for SparkThriftServer to support multi-tenant authentication for 
spark-2.4.0
URL: https://github.com/apache/spark/pull/25179#discussion_r304388906
 
 

 ##########
 File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
 ##########
 @@ -52,22 +54,55 @@ private[hive] class SparkSQLSessionManager(hiveServer: 
HiveServer2, sqlContext:
       sessionConf: java.util.Map[String, String],
       withImpersonation: Boolean,
       delegationToken: String): SessionHandle = {
-    val sessionHandle =
-      super.openSession(protocol, username, passwd, ipAddress, sessionConf, 
withImpersonation,
-          delegationToken)
-    val session = super.getSession(sessionHandle)
+    var session: HiveSession = null
+    var sparkSession: SparkSession = null
+    if (withImpersonation) {
+      val sessionWithUGI = new HiveSessionImplwithUGI(protocol, username, 
passwd, hiveConf, ipAddress, delegationToken)
+      val ugi = sessionWithUGI.getSessionUgi
+      val originalCreds = ugi.getCredentials
+      val creds = new Credentials()
+      ThriftServerHadoopUtil.doAs(ugi)(() => 
hadoopTokenProvider.obtainDelegationTokens(creds, username))
 
 Review comment:
   Should consider more about token expire.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to