Skip to content

Commit

Permalink
Adding conditions on claiming connections
Browse files Browse the repository at this point in the history
  • Loading branch information
DanMawdsleyBA committed Nov 4, 2023
1 parent c00813a commit d66a8a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class SnowflakeEncryptedPrivateKeyPemProfileMapping(BaseProfileMapping):
"private_key_passphrase": "password",
}

def can_claim_connection(self) -> bool:
# Make sure this isn't a private key path credential
result = super().can_claim_connection()
if (
result
and self.conn.extra_dejson.get("private_key_file") is not None
):
return False
return result

@property
def conn(self) -> Connection:
"""
Expand Down
10 changes: 10 additions & 0 deletions cosmos/profiles/snowflake/user_encrypted_privatekey_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class SnowflakeEncryptedPrivateKeyFilePemProfileMapping(BaseProfileMapping):
"private_key_path": "extra.private_key_file",
}

def can_claim_connection(self) -> bool:
# Make sure this isn't a private key enviroment variable
result = super().can_claim_connection()
if (
result
and self.conn.extra_dejson.get("private_key_content") is not None
):
return False
return result

@property
def conn(self) -> Connection:
"""
Expand Down

0 comments on commit d66a8a3

Please sign in to comment.