Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use native trino client authentication classes #16196

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mgorsk1
Copy link
Contributor

@mgorsk1 mgorsk1 commented May 9, 2024

Describe your changes:

Fixes

Since Trino client used in trino integration provides classes for different types of authentication (and includes both basic and jwt) classes I worked on refactoring trino/connection.py class to use them directly instead of workarounds with adjusting the connection url because it enables us to streamline inclusion of different authentication mechanisms and also enables us to use Oauth2Authentication class in a same way, which can be handy for some use cases. It will also make it super easy to extend in the future with other supported authentication mechanisms such as certificate or kerberos authentication.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

5 similar comments
Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Copy link

github-actions bot commented May 9, 2024

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Comment on lines +117 to +123
elif (
connection.authType
== noConfigAuthenticationTypes.NoConfigAuthenticationTypes.OAuth2
):
connection.connectionArguments.__root__["auth"] = OAuth2Authentication()
connection.connectionArguments.__root__["http_scheme"] = "https"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgorsk1 correct me if I'm wrong, but this method would only work if you are running a trino metadata job on your local machine via CLI mode where you have access to a browser, as OAuth2Authentication would print a link or redirect you to a the same link where you can complete the authentication

Copy link
Contributor Author

@mgorsk1 mgorsk1 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct, I added it because that's the scenario we needed and was not covered. The example scenario is:

  • trino configured with oauth2
  • trino npa used to fetch metadata from whole cluster (ingestion run from om airflow)
  • users run profiling jobs using OM SDK from their private environments
  • user credentials (collected from oauth2 flow) are used to run profiling jobs only on tables they have access to (we don't want users to run ad-hoc profiling jobs using strong trino npa)
  • profiling jobs takes time so we need a mechanism that will collect access_token but also refresh it - OAuth2Authentication handles this scenario while regular JWT doesn't

Copy link

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@pmbrull pmbrull added the safe to test Add this label to run secure Github workflows on PRs label May 10, 2024
@mgorsk1 mgorsk1 marked this pull request as ready for review May 10, 2024 14:26
@mgorsk1 mgorsk1 requested review from a team, akash-jain-10 and harshach as code owners May 10, 2024 14:26
@mgorsk1 mgorsk1 force-pushed the feat/trino-custom-auth-class branch from af94ac9 to 902c7be Compare May 11, 2024 15:28
@mgorsk1 mgorsk1 requested a review from ulixius9 May 15, 2024 11:34
Copy link

sonarcloud bot commented May 29, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Ingestion safe to test Add this label to run secure Github workflows on PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants