Skip to content

Commit 11a3db9

Browse files
committed
check admin
1 parent 5654a99 commit 11a3db9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,20 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
568568
content = Array(new Content(
569569
mediaType = MediaType.APPLICATION_JSON,
570570
schema = new Schema(implementation = classOf[ReassignBatchResponse]))),
571-
description = "Reassign batches to a new instance")
571+
description =
572+
"Reassign batch sessions on an unreachable kyuubi instance to the current kyuubi instance")
572573
@POST
573574
@Path("/reassign")
574575
@Consumes(Array(MediaType.APPLICATION_JSON))
575576
def reassignBatchSessions(request: ReassignBatchRequest): ReassignBatchResponse = {
577+
val userName = fe.getSessionUser(Map.empty[String, String])
578+
val ipAddress = fe.getIpAddress
576579
val kyuubiInstance = request.getKyuubiInstance
577580
val newKyuubiInstance = fe.connectionUrl
578-
info(s"Received request to reassign batch sessions from $kyuubiInstance to $newKyuubiInstance")
581+
info(s"Received reassign $kyuubiInstance batch sessions request from $userName/$ipAddress")
582+
if (!fe.isAdministrator(userName)) {
583+
throw new ForbiddenException(s"$userName is not allowed to reassign the batches")
584+
}
579585
if (kyuubiInstance == newKyuubiInstance) {
580586
throw new IllegalStateException(s"KyuubiInstance is alive: $kyuubiInstance")
581587
}

0 commit comments

Comments
 (0)