Skip to content

Commit

Permalink
Add Username + Password Authentication for Trino Client (fixes #829) (#…
Browse files Browse the repository at this point in the history
…1315)

* Add Username + Password Authentication for Trino Client (fixes #829)

* Making trino authentication backwards compatible

* Removing duplicate connection code
  • Loading branch information
rbb17 authored Aug 25, 2023
1 parent b39d358 commit 814781e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion querybook/server/lib/query_executor/clients/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
self,
connection_string: str,
username: Optional[str] = None,
password: Optional[str] = None,
proxy_user: Optional[str] = None,
*args: Any,
**kwargs: Any,
Expand All @@ -61,12 +62,17 @@ def __init__(
host = trino_conf.host
port = 8080 if not trino_conf.port else trino_conf.port

auth = trino.constants.DEFAULT_AUTH
if username is not None and password is not None:
auth = trino.auth.BasicAuthentication(username, password)

connection = trino.dbapi.connect(
host=host,
port=port,
catalog=trino_conf.catalog,
schema=trino_conf.schema,
user=proxy_user or username,
auth=auth,
user=proxy_user if proxy_user else username,
http_scheme=trino_conf.protocol,
)
self._connection = connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
),
),
("username", FormField(regex="\\w+")),
("impersonate", FormField(field_type=FormFieldType.Boolean)),
("password", FormField(hidden=True)),
(
"proxy_user_id",
FormField(
Expand Down

0 comments on commit 814781e

Please sign in to comment.