From 003da4d8dd3c4e3450ac43f5c2889a74db71d042 Mon Sep 17 00:00:00 2001 From: maxxie Date: Sun, 20 Jan 2019 23:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E5=B9=B6=E5=8F=91opensession=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8CrealUser=20=E5=8F=AF=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8F=A6=E4=B8=80=E4=B8=AAsession=20?= =?UTF-8?q?=E7=9A=84user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/yaooqinn/kyuubi/server/FrontendService.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kyuubi-server/src/main/scala/yaooqinn/kyuubi/server/FrontendService.scala b/kyuubi-server/src/main/scala/yaooqinn/kyuubi/server/FrontendService.scala index 2341620a6..861c5e9fe 100644 --- a/kyuubi-server/src/main/scala/yaooqinn/kyuubi/server/FrontendService.scala +++ b/kyuubi-server/src/main/scala/yaooqinn/kyuubi/server/FrontendService.scala @@ -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) @@ -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 @@ -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) } } @@ -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 => @@ -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) } }