Skip to content

feat(snowflake): add key pair (JWT) authentication#558

Merged
dosco merged 1 commit intodosco:masterfrom
amitdeshmukh:feat/snowflake-keypair-auth
Mar 28, 2026
Merged

feat(snowflake): add key pair (JWT) authentication#558
dosco merged 1 commit intodosco:masterfrom
amitdeshmukh:feat/snowflake-keypair-auth

Conversation

@amitdeshmukh
Copy link
Copy Markdown
Collaborator

Summary

  • Adds Snowflake key pair (JWT) authentication via three new config fields: private_key_path, private_key_pem, key_passphrase
  • Leverages gosnowflake driver's built-in JWT support (AuthTypeJwt) — no custom JWT code
  • Uses the existing driver.Connector pattern (same as MongoDB) when key pair auth is configured; plain DSN passthrough preserved when not

Changes

File Change
core/config.go PrivateKeyPath, PrivateKeyPEM, KeyPassphrase fields + SnowflakeKeyPairConfig interface
serv/config.go Same three fields on Database struct
serv/db.go loadSnowflakePrivateKey() helper + rewrote initSnowflake() with connector path
serv/init.go Multi-DB key pair branch in newDBFromDatabaseConfig()
serv/mcp_config.go Parse + sync new fields
serv/db_test.go 7 new unit tests (key loading, connector, fallback, error cases)
serv/mcp_test.go 1 new config parsing test
CONFIG.md Snowflake in DB table + full key pair auth docs with setup steps
README.md / FEATURES.md Added Snowflake to database support tables
cmd/tmpl/dev.yml Key pair config example

Test plan

  • TestLoadSnowflakePrivateKey_ValidPKCS8 — happy path
  • TestLoadSnowflakePrivateKey_InvalidPEM — bad PEM rejected
  • TestLoadSnowflakePrivateKey_NonRSAKey — EC key rejected with clear message
  • TestLoadSnowflakePrivateKey_PKCS1Rejected — PKCS#1 format rejected (PKCS#8 required)
  • TestInitSnowflake_KeyPairReturnsConnector — returns connector, not connString
  • TestInitSnowflake_PlainDSNFallback — existing behavior preserved
  • TestInitSnowflake_InvalidKeyPEM — bad inline PEM errors
  • TestParseDBConfig_SnowflakeKeyPair — MCP config map parsing
  • Full serv test suite passes
  • Manual verification with live Snowflake account + registered RSA public key

🤖 Generated with Claude Code

Snowflake's programmatic API uses JWT-based key pair auth (RSA-2048).
This wires up the gosnowflake driver's built-in JWT support via three
new config fields: private_key_path, private_key_pem, key_passphrase.

When key pair fields are set, the DSN is parsed via gosnowflake.ParseDSN,
the PKCS#8 private key is loaded, and a driver.Connector is created with
AuthTypeJwt — the same connector pattern MongoDB already uses. Plain DSN
passthrough is preserved when no key pair fields are configured.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dosco dosco merged commit 18b58af into dosco:master Mar 28, 2026
2 checks passed
dosco pushed a commit that referenced this pull request Apr 2, 2026
Snowflake's programmatic API uses JWT-based key pair auth (RSA-2048).
This wires up the gosnowflake driver's built-in JWT support via three
new config fields: private_key_path, private_key_pem, key_passphrase.

When key pair fields are set, the DSN is parsed via gosnowflake.ParseDSN,
the PKCS#8 private key is loaded, and a driver.Connector is created with
AuthTypeJwt — the same connector pattern MongoDB already uses. Plain DSN
passthrough is preserved when no key pair fields are configured.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@amitdeshmukh amitdeshmukh deleted the feat/snowflake-keypair-auth branch April 3, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants