You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2024/01/21 06:26:23 UTC
(kyuubi) branch master updated: [KYUUBI #5968] Support set authentication user for Trino engine
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 777b78443 [KYUUBI #5968] Support set authentication user for Trino engine
777b78443 is described below
commit 777b784439bd882dddeaca9215a8ee35335f96e3
Author: senmiaoliu <se...@trip.com>
AuthorDate: Sun Jan 21 14:26:12 2024 +0800
[KYUUBI #5968] Support set authentication user for Trino engine
# :mag: Description
## Issue References ๐
This pull request fixes #5968
## Describe Your Solution ๐ง
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
## Types of changes :bookmark:
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #5970 from lsm1/branch-kyuubi-5968.
Closes #5968
580eb45d2 [senmiaoliu] fix style
a36380cde [senmiaoliu] add auth user conf for trino engine
Authored-by: senmiaoliu <se...@trip.com>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
docs/configuration/settings.md | 1 +
.../org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala | 8 +++++---
.../src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala | 7 +++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md
index fa329e6b4..b203b0bda 100644
--- a/docs/configuration/settings.md
+++ b/docs/configuration/settings.md
@@ -194,6 +194,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co
| kyuubi.engine.trino.connection.truststore.password | <undefined> | The truststore password used for connecting to trino cluster [...]
| kyuubi.engine.trino.connection.truststore.path | <undefined> | The truststore path used for connecting to trino cluster [...]
| kyuubi.engine.trino.connection.truststore.type | <undefined> | The truststore type used for connecting to trino cluster [...]
+| kyuubi.engine.trino.connection.user | <undefined> | The user used for connecting to trino cluster [...]
| kyuubi.engine.trino.event.loggers | JSON | A comma-separated list of engine history loggers, where engine/session/operation etc events go.<ul> <li>JSON: the events will be written to the location of kyuubi.engine.event.json.log.path</li> <li>JDBC: to be done</li> <li>CUSTOM: to be done.</li></ul> [...]
| kyuubi.engine.trino.extra.classpath | <undefined> | The extra classpath for the Trino query engine, for configuring other libs which may need by the Trino engine [...]
| kyuubi.engine.trino.java.options | <undefined> | The extra Java options for the Trino query engine [...]
diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala
index 21aa921b9..674a67d0e 100644
--- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala
+++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala
@@ -54,7 +54,7 @@ class TrinoSessionImpl(
override val handle: SessionHandle =
conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).getOrElse(SessionHandle())
- private val username: String = sessionConf
+ private val sessionUser: String = sessionConf
.getOption(KyuubiReservedKeys.KYUUBI_SESSION_USER_KEY).getOrElse(currentUser)
var trinoContext: TrinoContext = _
@@ -95,7 +95,7 @@ class TrinoSessionImpl(
ClientSession.builder()
.server(URI.create(connectionUrl))
- .principal(Optional.of(username))
+ .principal(Optional.of(sessionUser))
.source("kyuubi")
.catalog(catalogName)
.schema(databaseName)
@@ -133,7 +133,9 @@ class TrinoSessionImpl(
require(
serverScheme.equalsIgnoreCase("https"),
"Trino engine using username/password requires HTTPS to be enabled")
- builder.addInterceptor(OkHttpUtil.basicAuth(username, password))
+ val user: String = sessionConf
+ .get(KyuubiConf.ENGINE_TRINO_CONNECTION_USER).getOrElse(sessionUser)
+ builder.addInterceptor(OkHttpUtil.basicAuth(user, password))
}
builder.build()
diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
index 9f0752754..3eedfdded 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
@@ -1388,6 +1388,13 @@ object KyuubiConf {
.stringConf
.createOptional
+ val ENGINE_TRINO_CONNECTION_USER: OptionalConfigEntry[String] =
+ buildConf("kyuubi.engine.trino.connection.user")
+ .doc("The user used for connecting to trino cluster")
+ .version("1.9.0")
+ .stringConf
+ .createOptional
+
val ENGINE_TRINO_CONNECTION_PASSWORD: OptionalConfigEntry[String] =
buildConf("kyuubi.engine.trino.connection.password")
.doc("The password used for connecting to trino cluster")