Skip to content

[SNAP-1951] move authentication handler bind to be inside connect #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions core/src/main/scala/org/apache/spark/ui/JettyUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,6 @@ private[spark] object JettyUtils extends Logging {

val gzipHandlers = handlers.map { h =>
h.setVirtualHosts(Array("@" + SPARK_CONNECTOR_NAME))
// set Security Handler
customAuthenticator match {
case Some(auth) =>
h.setSecurityHandler(basicAuthenticationHandler())
case None =>
logDebug("Not setting auth handler")
}
val gzipHandler = new GzipHandler
gzipHandler.setHandler(h)
gzipHandler
Expand All @@ -329,6 +322,18 @@ private[spark] object JettyUtils extends Logging {
}
pool.setDaemon(true)

// Set SnappyData authenticator into the SecurityHandler.
// Has to be done inside connect because a failure to bind to port will
// clear the handler so auth will fail even if bind on next port succeeds.
customAuthenticator match {
case Some(_) =>
gzipHandlers.foreach { gh =>
gh.getHandler.asInstanceOf[ServletContextHandler]
.setSecurityHandler(basicAuthenticationHandler())
}
case None => logDebug("Not setting auth handler")
}

val server = new Server(pool)
val connectors = new ArrayBuffer[ServerConnector]()
val collection = new ContextHandlerCollection
Expand Down