Skip to content

Commit

Permalink
[dagster-snowflake] remove password check for private key auth for un…
Browse files Browse the repository at this point in the history
…encrypted keys (#11745)
  • Loading branch information
jamiedemaria committed Jan 18, 2023
1 parent 8e7ea32 commit 822676a
Showing 1 changed file with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ def __init__(self, config: Mapping[str, str], log): # pylint: disable=too-many-
),
)

# if private key auth is used, ensure the password is provided
if (
config.get("private_key", None) is not None
or config.get("private_key_path", None) is not None
):
check.invariant(
config.get("private_key_password", None) is not None,
(
"Incorrect config: Must provide private_key_password for private key"
" authentication with Snowflake resource."
),
)

if self.connector == "sqlalchemy":
self.conn_args: Dict[str, Any] = {
k: config.get(k)
Expand Down Expand Up @@ -141,11 +128,11 @@ def __snowflake_private_key(self, config) -> bytes:
with open(config.get("private_key_path"), "rb") as key:
private_key = key.read()

p_key = serialization.load_pem_private_key(
private_key,
password=config.get("private_key_password", None).encode(),
backend=default_backend(),
)
kwargs = {}
if config.get("private_key_password", None) is not None:
kwargs["password"] = config["private_key_password"].encode()

p_key = serialization.load_pem_private_key(private_key, backend=default_backend(), **kwargs)

pkb = p_key.private_bytes(
encoding=serialization.Encoding.DER,
Expand Down

0 comments on commit 822676a

Please sign in to comment.