-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1825473 adding pat authentication integration (#2122)
- Loading branch information
1 parent
5d7064c
commit 1dc673f
Showing
8 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
import typing | ||
|
||
from snowflake.connector.network import PROGRAMMATIC_ACCESS_TOKEN | ||
|
||
from .by_plugin import AuthByPlugin, AuthType | ||
|
||
|
||
class AuthByPAT(AuthByPlugin): | ||
|
||
def __init__(self, pat_token: str, **kwargs) -> None: | ||
super().__init__(**kwargs) | ||
self._pat_token: str | None = pat_token | ||
|
||
def type_(self) -> AuthType: | ||
return AuthType.PAT | ||
|
||
def reset_secrets(self) -> None: | ||
self._pat_token = None | ||
|
||
def update_body(self, body: dict[typing.Any, typing.Any]) -> None: | ||
body["data"]["AUTHENTICATOR"] = PROGRAMMATIC_ACCESS_TOKEN | ||
body["data"]["TOKEN"] = self._pat_token | ||
|
||
def prepare( | ||
self, | ||
**kwargs: typing.Any, | ||
) -> None: | ||
"""Nothing to do here, token should be obtained outside the driver.""" | ||
pass | ||
|
||
def reauthenticate(self, **kwargs: typing.Any) -> dict[str, bool]: | ||
return {"success": False} | ||
|
||
@property | ||
def assertion_content(self) -> str | None: | ||
"""Returns the token.""" | ||
return self._pat_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters