Skip to content

Commit

Permalink
[KYUUBI #5968] Support set authentication user for Trino engine
Browse files Browse the repository at this point in the history
# 🔍 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 🔖

- [ ] 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 ⚰️

#### Behavior With This Pull Request 🎉

#### 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

580eb45 [senmiaoliu] fix style
a36380c [senmiaoliu] add auth user conf for trino engine

Authored-by: senmiaoliu <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
  • Loading branch information
lsm1 authored and pan3793 committed Jan 21, 2024
1 parent bd83f89 commit 777b784
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/configuration/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co
| kyuubi.engine.trino.connection.truststore.password | &lt;undefined&gt; | The truststore password used for connecting to trino cluster | string | 1.8.0 |
| kyuubi.engine.trino.connection.truststore.path | &lt;undefined&gt; | The truststore path used for connecting to trino cluster | string | 1.8.0 |
| kyuubi.engine.trino.connection.truststore.type | &lt;undefined&gt; | The truststore type used for connecting to trino cluster | string | 1.8.0 |
| kyuubi.engine.trino.connection.user | &lt;undefined&gt; | The user used for connecting to trino cluster | string | 1.9.0 |
| 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> | seq | 1.7.0 |
| kyuubi.engine.trino.extra.classpath | &lt;undefined&gt; | The extra classpath for the Trino query engine, for configuring other libs which may need by the Trino engine | string | 1.6.0 |
| kyuubi.engine.trino.java.options | &lt;undefined&gt; | The extra Java options for the Trino query engine | string | 1.6.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = _
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 777b784

Please sign in to comment.