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

Draft: Implement support for external oauth #46

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

Conversation

wseaton
Copy link
Contributor

@wseaton wseaton commented Jun 6, 2024

WIP for #36

Took the liberty of refactoring some of the internal session functions along the way, opening this to discuss how that is best done mostly. Current refactoring is going to potentially result in some API breakage.

External Oauth is tested to work on my account.

@sbose78
Copy link

sbose78 commented Jun 7, 2024

Hey, very cool, @wseaton !

schema: args.schema,
username: args.username,
role: args.role,
auth_type: snowflake_api::AuthType::Password(PasswordArgs {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of having two different internal AuthType enums with slightly different purposes, what if SnowflakeApi was just generic over an AuthType trait, that implements functions for building the login flow? I think that would clean the code up a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SnowflakeApi<OAuth> where OAuth impl AuthType, etc.

}
AuthType::OAuth(token) => {
log::info!("Starting session with oauth authentication");
self.create(self.oauth_request_body(token)).await
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's where we'd want to use generics on the AuthType trait and implement get_request_body for each auth type.

@colin99d
Copy link
Contributor

This is very cool! Something we were looking into ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants