[KYUUBI #3739] [REST] Remove unused parameters in SessionOpenRequest

### _Why are the changes needed?_

We should put the authorization info in request header, user,password,ip in SessionOpenRequest are unnecessary.

### _How was this patch tested?_
- [X] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #3739 from hddong/rm-unused-params.

Closes #3739

7fac61853 [hongdongdong] update
8f1f4ae01 [hongdongdong] added on migration guide
95962b472 [hongdongdong] fix
63606350b [hongdongdong] [REST] Remove unused parameters in SessionOpenRequest

Authored-by: hongdongdong <hongdd@apache.org>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
hongdongdong 2023-01-11 10:16:55 +08:00 committed by fwang12
parent 679810fe11
commit 2d41081d7b
5 changed files with 13 additions and 59 deletions

View File

@ -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`.

View File

@ -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<String, String> configs;
public SessionOpenRequest() {}
public SessionOpenRequest(
int protocolVersion,
String user,
String password,
String ipAddr,
Map<String, String> configs) {
public SessionOpenRequest(int protocolVersion, Map<String, String> 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<String, String> 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

View File

@ -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,

View File

@ -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)

View File

@ -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")