Skip to content

Commit

Permalink
disable web ui
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm1 committed Apr 15, 2024
1 parent cefc27f commit b845f11
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@ object KyuubiConf {
.timeConf
.createWithDefaultString("PT5S")

val FRONTEND_REST_ENABLE_WEBUI: ConfigEntry[Boolean] =
buildConf("kyuubi.frontend.rest.enable.webui")
.doc("If set to false then web ui will disabled when RESTful protocol is enabled")
.version("1.10.0")
.booleanConf
.createWithDefault(true)

val FRONTEND_WORKER_KEEPALIVE_TIME: ConfigEntry[Long] =
buildConf("kyuubi.frontend.worker.keepalive.time")
.doc("(deprecated) Keep-alive time (in milliseconds) for an idle worker thread")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
}

private def installWebUI(): Unit = {
if (!conf.get(FRONTEND_REST_ENABLE_WEBUI)) {
val filterHolder = new FilterHolder(JettyUtils.createFilter("/enable.html"))
val servletHandler = JettyUtils.createStaticHandler("dist", "/")
servletHandler.addFilter(filterHolder, "/*", null)
server.addHandler(servletHandler)
return
}
// redirect root path to Web UI home page
server.addRedirectHandler("/", "/ui")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kyuubi.server.ui

import java.net.URL
import javax.servlet.{Filter, FilterChain, FilterConfig, ServletRequest, ServletResponse}
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}

import org.eclipse.jetty.servlet.{DefaultServlet, ServletContextHandler, ServletHolder}
Expand Down Expand Up @@ -87,4 +88,24 @@ private[kyuubi] object JettyUtils {
createServletHandler(src, redirectedServlet)

}

def createFilter(targetPage: String): Filter = new Filter {
override def init(filterConfig: FilterConfig): Unit = {}

override def doFilter(
request: ServletRequest,
response: ServletResponse,
chain: FilterChain): Unit = {
val httpRequest = request.asInstanceOf[HttpServletRequest]
val httpResponse = response.asInstanceOf[HttpServletResponse]
val requestURI = httpRequest.getRequestURI
if (requestURI != targetPage) {
httpResponse.sendRedirect(httpRequest.getContextPath + targetPage)
} else {
chain.doFilter(request, response)
}
}

override def destroy(): Unit = {}
}
}
29 changes: 29 additions & 0 deletions kyuubi-server/web-ui/public/enable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Apache Kyuubi</title>
</head>
<body>
<h2 style="text-align: center;">🙁 The Web UI is currently unavailable.</h2>
<h4 style="text-align: center;">👉 To enable Web UI, set kyuubi.frontend.rest.enable.webui true.</h4>
</body>
</html>

0 comments on commit b845f11

Please sign in to comment.