diff --git a/docs/deployment/migration-guide.md b/docs/deployment/migration-guide.md index daab1be5d..86efd7a0c 100644 --- a/docs/deployment/migration-guide.md +++ b/docs/deployment/migration-guide.md @@ -24,6 +24,7 @@ * Since Kyuubi 1.7, Kyuubi returns engine's information for `GetInfo` request instead of server. To restore the previous behavior, set `kyuubi.server.info.provider` to `SERVER`. * Since Kyuubi 1.7, Kyuubi session type `SQL` is refactored to `INTERACTIVE`, because Kyuubi supports not only `SQL` session, but also `SCALA` and `PYTHON` sessions. User need to use `INTERACTIVE` sessionType to look up the session event. +* Since Kyuubi 1.7, the REST API of `Open(create) a session` will not contains parameters `user` `password` and `IpAddr`. User and password should be set in `Authorization` of http request if needed. ## Upgrading from Kyuubi 1.6.0 to 1.6.1 * Since Kyuubi 1.6.1, `kyuubi.ha.zookeeper.engine.auth.type` does not fallback to `kyuubi.ha.zookeeper.auth.type`. diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java index 4c8a8dfce..2d23aac57 100644 --- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java +++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java @@ -25,23 +25,12 @@ import org.apache.commons.lang3.builder.ToStringStyle; public class SessionOpenRequest { private int protocolVersion; - private String user; - private String password; - private String ipAddr; private Map configs; public SessionOpenRequest() {} - public SessionOpenRequest( - int protocolVersion, - String user, - String password, - String ipAddr, - Map configs) { + public SessionOpenRequest(int protocolVersion, Map configs) { this.protocolVersion = protocolVersion; - this.user = user; - this.password = password; - this.ipAddr = ipAddr; this.configs = configs; } @@ -53,30 +42,6 @@ public class SessionOpenRequest { this.protocolVersion = protocolVersion; } - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getIpAddr() { - return ipAddr; - } - - public void setIpAddr(String ipAddr) { - this.ipAddr = ipAddr; - } - public Map getConfigs() { if (null == configs) { return Collections.emptyMap(); @@ -94,15 +59,12 @@ public class SessionOpenRequest { if (o == null || getClass() != o.getClass()) return false; SessionOpenRequest that = (SessionOpenRequest) o; return getProtocolVersion() == that.getProtocolVersion() - && Objects.equals(getUser(), that.getUser()) - && Objects.equals(getPassword(), that.getPassword()) - && Objects.equals(getIpAddr(), that.getIpAddr()) && Objects.equals(getConfigs(), that.getConfigs()); } @Override public int hashCode() { - return Objects.hash(getProtocolVersion(), getUser(), getPassword(), getIpAddr(), getConfigs()); + return Objects.hash(getProtocolVersion(), getConfigs()); } @Override diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala index 17e23c58d..80212faf2 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala @@ -146,7 +146,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging { val handle = fe.be.openSession( TProtocolVersion.findByValue(request.getProtocolVersion), userName, - request.getPassword, + "", ipAddress, (request.getConfigs.asScala ++ Map( KYUUBI_CLIENT_IP_KEY -> ipAddress, diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala index a46c52572..64707ce01 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala @@ -131,9 +131,6 @@ class KyuubiRestAuthenticationSuite extends RestClientTestHelper { var token = generateToken(hostName) val sessionOpenRequest = new SessionOpenRequest( TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11.getValue, - "kyuubi", - "pass", - "localhost", Map( KyuubiConf.ENGINE_SHARE_LEVEL.key -> "CONNECTION", "hive.server2.proxy.user" -> proxyUser).asJava) diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala index 7f3f52104..db5e1360b 100644 --- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala +++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala @@ -17,7 +17,9 @@ package org.apache.kyuubi.server.api.v1 +import java.nio.charset.StandardCharsets import java.util +import java.util.Base64 import javax.ws.rs.client.Entity import javax.ws.rs.core.{GenericType, MediaType, Response} @@ -32,6 +34,7 @@ import org.apache.kyuubi.config.KyuubiReservedKeys.KYUUBI_SESSION_CONNECTION_URL import org.apache.kyuubi.events.KyuubiSessionEvent import org.apache.kyuubi.metrics.{MetricsConstants, MetricsSystem} import org.apache.kyuubi.operation.OperationHandle +import org.apache.kyuubi.server.http.authentication.AuthenticationHandler.AUTHORIZATION_HEADER import org.apache.kyuubi.session.SessionType class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { @@ -46,9 +49,6 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { test("open/close and count session") { val requestObj = new SessionOpenRequest( 1, - "admin", - "123456", - "localhost", Map("testConfig" -> "testValue").asJava) var response = webTarget.path("api/v1/sessions") @@ -82,9 +82,6 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { test("getSessionList") { val requestObj = new SessionOpenRequest( 1, - "admin", - "123456", - "localhost", Map("testConfig" -> "testValue").asJava) var response = webTarget.path("api/v1/sessions") @@ -113,13 +110,15 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { test("get session event") { val sessionOpenRequest = new SessionOpenRequest( 1, - "admin", - "123456", - "localhost", Map("testConfig" -> "testValue").asJava) + val user = "kyuubi".getBytes() + val sessionOpenResp = webTarget.path("api/v1/sessions") .request(MediaType.APPLICATION_JSON_TYPE) + .header( + AUTHORIZATION_HEADER, + s"Basic ${new String(Base64.getEncoder().encode(user), StandardCharsets.UTF_8)}") .post(Entity.entity(sessionOpenRequest, MediaType.APPLICATION_JSON_TYPE)) val sessionHandle = sessionOpenResp.readEntity(classOf[SessionHandle]).getIdentifier @@ -130,6 +129,7 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { val sessions = response.readEntity(classOf[KyuubiSessionEvent]) assert(sessions.conf("testConfig").equals("testValue")) assert(sessions.sessionType.equals(SessionType.INTERACTIVE.toString)) + assert(sessions.user.equals("kyuubi")) // close an opened session response = webTarget.path(s"api/v1/sessions/$sessionHandle").request().delete() @@ -148,9 +148,6 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { val requestObj = new SessionOpenRequest( 1, - "admin", - "123456", - "localhost", Map("testConfig" -> "testValue", KyuubiConf.SERVER_INFO_PROVIDER.key -> "SERVER").asJava) var response: Response = webTarget.path("api/v1/sessions") @@ -192,9 +189,6 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper { test("submit operation and get operation handle") { val requestObj = new SessionOpenRequest( 1, - "admin", - "123456", - "localhost", Map("testConfig" -> "testValue").asJava) var response: Response = webTarget.path("api/v1/sessions")