mgaido91 commented on a change in pull request #141: [LIVY-551] Add "doAs" 
impersonation support
URL: https://github.com/apache/incubator-livy/pull/141#discussion_r252153640
 
 

 ##########
 File path: server/src/main/scala/org/apache/livy/server/SessionServlet.scala
 ##########
 @@ -156,9 +156,29 @@ abstract class SessionServlet[S <: Session, R <: 
RecoveryMetadata](
   }
 
   /**
-   * Returns the remote user for the given request. Separate method so that 
tests can override it.
-   */
-  protected def remoteUser(req: HttpServletRequest): String = 
req.getRemoteUser()
+    * Returns the remote user for the given request. Separate method so that 
tests can override it.
+    */
+  protected def remoteUser(req: HttpServletRequest): String = req.getRemoteUser
+
+  protected def impersonatedUser(request: HttpServletRequest): Option[String] 
= {
+    val impersonatedUser = Option(request.getParameter("doAs"))
+    
impersonatedUser.filter(accessManager.checkImpersonation(remoteUser(request), 
_))
+  }
+
+  /**
+    * Returns the proxy user as determined by the json request body or owner 
if available.
 
 Review comment:
   nit: bad indent

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


With regards,
Apache Git Services

Reply via email to