Repository navigation
Conversation
Add a plugin for Snowflake CLI (snow) that authenticates with key pair (SNOWFLAKE_JWT). A temporary config.toml defining a single connection is passed via --config-file, and the private key and its passphrase are provisioned as environment variables so they are never written to disk.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a new shell plugin,
snowflakecli, for Snowflake CLI (snow), with support for key pair authentication (SNOWFLAKE_JWT).It is added as a separate plugin because the existing
snowflakeplugin targets a different CLI. The two plugins run different executables, so they can be used side by side without conflicts.snowflake(existing)snowflakecli(this PR)snowsql)snow)SNOWFLAKE_JWT)~/.snowsql/config(INI)config.toml/connections.toml(TOML)SNOWSQL_*environment variablesSNOWFLAKE_*environment variables and-xThe plugin is named
snowflakeclibecause plugin names can't contain hyphens (they must match the Go package name).Credential
Provisioning
SNOWFLAKE_ACCOUNT,SNOWFLAKE_USER,SNOWFLAKE_AUTHENTICATOR=SNOWFLAKE_JWT,SNOWFLAKE_PRIVATE_KEY_RAW,PRIVATE_KEY_PASSPHRASE, etc.), and-x(--temporary-connection) is appended to the command. The private key is never written to disk.-xis needed:snowrequires either a connection name or-x, and the genericSNOWFLAKE_*environment variables have lower precedence than the values in the user's config files.--config-filedoesn't work:snowopens its config file multiple times, so it hangs while reading the provisioned file.-c/--connection,-x, or--config-fileis specified.connection add|list|remove|set-default,helpers,init,plugin,upgrade,app bundle, etc.) are also skipped, since they don't accept-x.\nsequences or spaces), they are restored to valid PEM format at runtime.Importer
SNOWFLAKE_*andPRIVATE_KEY_PASSPHRASE. The private key file pointed to bySNOWFLAKE_PRIVATE_KEY_FILE/SNOWFLAKE_PRIVATE_KEY_PATHis read as well, so a multi-line PEM key can be imported without pasting it into the prompt.config.toml/connections.tomlin~/.snowflake/,~/Library/Application Support/snowflake/(macOS), and~/.config/snowflake/(Linux). Only connections withauthenticator = "SNOWFLAKE_JWT"are imported, and the key file is read ifprivate_key_file/private_key_pathis set.Type of change
Related Issue(s)
How To Test
Prerequisites: a Snowflake user with a registered public key (
ALTER USER <user> SET RSA_PUBLIC_KEY='...') and the corresponding PKCS#8 private key.Tested with Snowflake CLI 3.27.0.
Changelog
Authenticate Snowflake CLI with key pair authentication using Touch ID and other unlock options with 1Password Shell Plugins.