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

SNOW-1825473 adding pat authentication integration #2122

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

sfc-gh-mkeller
Copy link
Collaborator

@sfc-gh-mkeller sfc-gh-mkeller commented Dec 16, 2024

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1825473

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    In this PR I introduce support for the new PAT authentication method. We don't have automated tests for all the different authentication methods, so the code was tested manually.

  4. (Optional) PR for stored-proc connector:

@sfc-gh-mkeller sfc-gh-mkeller added the DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector label Dec 16, 2024
@sfc-gh-mkeller sfc-gh-mkeller self-assigned this Dec 16, 2024
@@ -22,7 +22,7 @@ def type_(self) -> AuthType:
return AuthType.OAUTH

@property
def assertion_content(self) -> str:
def assertion_content(self) -> str | None:
Copy link

@sfc-gh-igarish sfc-gh-igarish Dec 17, 2024

Choose a reason for hiding this comment

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

Why added None here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The type-hint was incorrect. It doesn't actually affect correctness, but you can see a few lines below that the function reset_secrets sets what this returns to None

@@ -187,6 +187,7 @@
OAUTH_AUTHENTICATOR = "OAUTH"
ID_TOKEN_AUTHENTICATOR = "ID_TOKEN"
USR_PWD_MFA_AUTHENTICATOR = "USERNAME_PASSWORD_MFA"
PROGRAMMATIC_ACCESS_TOKEN = "PROGRAMMATIC_ACCESS_TOKEN"

Choose a reason for hiding this comment

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

How user will provide authentication name in connection parameter? like "PROGRAMMATIC_ACCESS_TOKEN"? If yes, then can we use "PAT" instead of long name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the exact shell command I was using to test the feature: python -c 'from snowflake.connector import connect; c=connect(account="account", user="user", authenticator="PROGRAMMATIC_ACCESS_TOKEN", token_file_path="/Users/mkeller/pat"); print(c.cursor().execute("select 1, 2").fetchall())'

I haven't introduced the short form simply because we don't offer short-hands for any of the other authentications. I'm happy to introduce it if you think we should start now though!

Copy link

@sfc-gh-igarish sfc-gh-igarish left a comment

Choose a reason for hiding this comment

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

LGTM

@sfc-gh-mkeller sfc-gh-mkeller merged commit 1dc673f into main Dec 17, 2024
95 checks passed
@sfc-gh-mkeller sfc-gh-mkeller deleted the mkeller/SNOW-1825473/pat-implementation branch December 17, 2024 19:33
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants