Skip to content

Commit

Permalink
Add oauth_console authentication type
Browse files Browse the repository at this point in the history
  • Loading branch information
hovaesco committed Nov 30, 2023
1 parent 22720e3 commit bdac979
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dbt/adapters/trino/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def _create_trino_profile(cls, profile):
return TrinoJwtCredentials
elif method == "oauth":
return TrinoOauthCredentials
elif method == "oauth_console":
return TrinoOauthConsoleCredentials
return TrinoNoneCredentials

@classmethod
Expand Down Expand Up @@ -273,6 +275,35 @@ def trino_auth(self):
return self.OAUTH


@dataclass
class TrinoOauthConsoleCredentials(TrinoCredentials):
host: str
port: Port
user: Optional[str] = None
client_tags: Optional[List[str]] = None
roles: Optional[Dict[str, str]] = None
cert: Optional[str] = None
http_headers: Optional[Dict[str, str]] = None
session_properties: Dict[str, Any] = field(default_factory=dict)
prepared_statements_enabled: bool = PREPARED_STATEMENTS_ENABLED_DEFAULT
retries: Optional[int] = trino.constants.DEFAULT_MAX_ATTEMPTS
timezone: Optional[str] = None
OAUTH = trino.auth.OAuth2Authentication(
redirect_auth_url_handler=trino.auth.ConsoleRedirectHandler()
)

@property
def http_scheme(self):
return HttpScheme.HTTPS

@property
def method(self):
return "oauth_console"

def trino_auth(self):
return self.OAUTH


class ConnectionWrapper(object):
"""Wrap a Trino connection in a way that accomplishes two tasks:
Expand Down

0 comments on commit bdac979

Please sign in to comment.