Snowflake-Labs / schemachange

A Database Change Management tool for Snowflake
Apache License 2.0
517 stars 228 forks source link

Need a feature where we can pull the private key directly from os.environ["SNOWFLAKE_PRIVATE_KEY"], instead of having an option where it should be in a file only. #252

Open nk-reichenbach-fall opened 6 months ago

nk-reichenbach-fall commented 6 months ago

Is your feature request related to a problem? Please describe. Sometimes we don't want to store the keys in file and we directly want to use them. Current implementation, doesn't allows it.

Describe the solution you'd like we can pull the private key directly from os.environ["SNOWFLAKE_PRIVATE_KEY"]

elif os.getenv("SNOWFLAKE_PRIVATE_KEY"):
    SF_PK = os.environ["SNOWFLAKE_PRIVATE_KEY"]

    key = str.encode(SF_PKB)

    with BytesIO(key) as pp_key:
        p_key = serialization.load_pem_private_key(
            pp_key.read(), password=None, backend=default_backend()
        )

    pkb = p_key.private_bytes(
                encoding = serialization.Encoding.DER,
                format = serialization.PrivateFormat.PKCS8,
                encryption_algorithm = serialization.NoEncryption())

    self.conArgs['private_key'] = pkb

Describe alternatives you've considered NA

Additional context NA