Skip to content

Commit

Permalink
Merge pull request #146 from Neilxzn/master
Browse files Browse the repository at this point in the history
修复可能存在并发opensession的时候,realUser 可能会获取另一个session 的user
  • Loading branch information
yaooqinn committed Jan 21, 2019
2 parents 293265e + 003da4d commit 8979fc5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private[kyuubi] class FrontendService private(name: String, beService: BackendSe

private var isStarted = false

private var realUser: String = _

def this(beService: BackendService) = {
this(classOf[FrontendService].getSimpleName, beService)
Expand Down Expand Up @@ -155,6 +154,7 @@ private[kyuubi] class FrontendService private(name: String, beService: BackendSe
}

private def getUserName(req: TOpenSessionReq): String = {
var realUser: String = null
// Kerberos
if (isKerberosAuthMode) {
realUser = authFactory.getRemoteUser.orNull
Expand All @@ -171,7 +171,7 @@ private[kyuubi] class FrontendService private(name: String, beService: BackendSe
if (req.getConfiguration == null) {
realUser
} else {
getProxyUser(req.getConfiguration.asScala.toMap, getIpAddress)
getProxyUser(req.getConfiguration.asScala.toMap, getIpAddress, realUser)
}
}

Expand All @@ -185,7 +185,8 @@ private[kyuubi] class FrontendService private(name: String, beService: BackendSe
}

@throws[KyuubiSQLException]
private def getProxyUser(sessionConf: Map[String, String], ipAddress: String): String = {
private def getProxyUser(sessionConf: Map[String, String],
ipAddress: String, realUser: String): String = {
Option(sessionConf).flatMap(_.get(KyuubiAuthFactory.HS2_PROXY_USER)) match {
case None => realUser
case Some(_) if !conf.get(FRONTEND_ALLOW_USER_SUBSTITUTION).toBoolean =>
Expand Down Expand Up @@ -609,7 +610,7 @@ private[kyuubi] class FrontendService private(name: String, beService: BackendSe
server.foreach(_.serve())
} catch {
case t: Throwable =>
error("Error starting " + name + " for KyuubiServer", t)
error("Error starting " + name + " for KyuubiServer", t)
System.exit(-1)
}
}
Expand Down

0 comments on commit 8979fc5

Please sign in to comment.