Skip to content

Commit

Permalink
rename and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lightning-L committed Feb 26, 2023
1 parent 7324cab commit 1a01a75
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/deployment/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co

| Key | Default | Meaning | Type | Since |
|----------------------------------------------------------|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-------|
| kyuubi.server.admin.users || Comma-separated list of Kyuubi service admin users. We use this config to grant admin permission to any service accounts. | seq | 1.8.0 |
| kyuubi.server.administrators || Comma-separated list of Kyuubi service administrators. We use this config to grant admin permission to any service accounts. | seq | 1.8.0 |
| kyuubi.server.info.provider | ENGINE | The server information provider name, some clients may rely on this information to check the server compatibilities and functionalities. <li>SERVER: Return Kyuubi server information.</li> <li>ENGINE: Return Kyuubi engine information.</li> | string | 1.6.1 |
| kyuubi.server.limit.batch.connections.per.ipaddress | &lt;undefined&gt; | Maximum kyuubi server batch connections per ipaddress. Any user exceeding this limit will not be allowed to connect. | int | 1.7.0 |
| kyuubi.server.limit.batch.connections.per.user | &lt;undefined&gt; | Maximum kyuubi server batch connections per user. Any user exceeding this limit will not be allowed to connect. | int | 1.7.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2429,15 +2429,15 @@ object KyuubiConf {
.timeConf
.createWithDefaultString("PT30M")

val SERVER_ADMIN_USERS: ConfigEntry[Seq[String]] =
buildConf("kyuubi.server.admin.users")
.doc("Comma-separated list of Kyuubi service admin users. " +
val SERVER_ADMINISTRATORS: ConfigEntry[Seq[String]] =
buildConf("kyuubi.server.administrators")
.doc("Comma-separated list of Kyuubi service administrators. " +
"We use this config to grant admin permission to any service accounts.")
.version("1.8.0")
.serverOnly
.stringConf
.toSequence()
.createWithDefault(Seq.empty)
.createWithDefault(Nil)

val OPERATION_SPARK_LISTENER_ENABLED: ConfigEntry[Boolean] =
buildConf("kyuubi.operation.spark.listener.enabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import org.apache.kyuubi.server.api.ApiRequestContext
@Tag(name = "Admin")
@Produces(Array(MediaType.APPLICATION_JSON))
private[v1] class AdminResource extends ApiRequestContext with Logging {
private lazy val administrators = Set(Utils.currentUser) ++
fe.getConf.get(KyuubiConf.SERVER_ADMIN_USERS)
private lazy val administrators = fe.getConf.get(KyuubiConf.SERVER_ADMINISTRATORS).toSet +
Utils.currentUser

@ApiResponse(
responseCode = "200",
Expand All @@ -55,7 +55,7 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
val userName = fe.getSessionUser(Map.empty[String, String])
val ipAddress = fe.getIpAddress
info(s"Receive refresh Kyuubi server hadoop conf request from $userName/$ipAddress")
if (!administrators.contains(userName)) {
if (!isAdministrator(userName)) {
throw new NotAllowedException(
s"$userName is not allowed to refresh the Kyuubi server hadoop conf")
}
Expand All @@ -74,7 +74,7 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
val userName = fe.getSessionUser(Map.empty[String, String])
val ipAddress = fe.getIpAddress
info(s"Receive refresh user defaults conf request from $userName/$ipAddress")
if (!administrators.contains(userName)) {
if (!isAdministrator(userName)) {
throw new NotAllowedException(
s"$userName is not allowed to refresh the user defaults conf")
}
Expand All @@ -93,7 +93,7 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
val userName = fe.getSessionUser(Map.empty[String, String])
val ipAddress = fe.getIpAddress
info(s"Receive refresh unlimited users request from $userName/$ipAddress")
if (!administrators.contains(userName)) {
if (!isAdministrator(userName)) {
throw new NotAllowedException(
s"$userName is not allowed to refresh the unlimited users")
}
Expand Down Expand Up @@ -213,4 +213,8 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
engine.getUser,
engine.getSubdomain)
}

private def isAdministrator(userName: String): Boolean = {
administrators.contains(userName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AdminResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
private val engineMgr = new KyuubiApplicationManager()

override protected lazy val conf: KyuubiConf = KyuubiConf()
.set(KyuubiConf.SERVER_ADMIN_USERS, Seq("admin001"))
.set(KyuubiConf.SERVER_ADMINISTRATORS, Seq("admin001"))

override def beforeAll(): Unit = {
super.beforeAll()
Expand Down

0 comments on commit 1a01a75

Please sign in to comment.