davsclaus opened a new pull request, #3208: URL: https://github.com/apache/camel-kamelets/pull/3208
Part of #3170: `snowflake-source` and `snowflake-sink` can log in with a key pair, as well as with a password. ### The problem Both Kamelets logged in only with `username` and `password`. Snowflake is phasing out sign-in with a password alone: - Snowflake's [user management page](https://docs.snowflake.com/en/user-guide/admin-user-management) says users of `TYPE=SERVICE` "cannot log in using a password". The [CREATE USER reference](https://docs.snowflake.com/en/sql-reference/sql/create-user) describes `LEGACY_SERVICE` as "similar to SERVICE, but allows password authentication", and says that type is being deprecated. - Snowflake's [rollout plan](https://docs.snowflake.com/en/user-guide/security-mfa-rollout) (read on 2026-11-18) has three phases: - Sep 2025 to Jan 2026: MFA becomes mandatory for people who sign in to Snowsight with a password. - May to Jul 2026: new users need strong authentication, and `LEGACY_SERVICE` can no longer be set. - Aug to Oct 2026: "human users cannot authenticate with a password alone", "all non-human users are blocked from using a password", and `LEGACY_SERVICE` users are migrated to `SERVICE`. Enforcement dates "vary by account, and may be extended". Reader accounts, trial accounts and Snowflake Postgres are exempt. So a Kamelet that can only send a password stops working for a service user. Snowflake documents [key-pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth) for clients like this one. ### The options The data source bean is still `SnowflakeDataSourceFactory.createDataSource()`. The driver is `snowflake-jdbc` 4.3.4, as `spec.dependencies` declares. Its `setPrivateKeyBase64(key, pwd)` and `setPrivateKeyFile(path, pwd)` take two arguments, so a bean property cannot call them. The template therefore puts the driver's connection properties into the data source's `properties` map. The property names are taken from `SFSessionProperty` in the 4.3.4 sources. | Option | Template mapping (bean `dsBean`) | What it does | |---|---|---| | `privateKey` | `properties[private_key_base64]: "{{?privateKey}}"` | The private key file in PEM format, encoded in base64 on one line (`base64 -w0 rsa_key.p8`). `format: password`. | | `privateKeyFile` | `properties[private_key_file]: "{{?privateKeyFile}}"` | The path of the PEM key file, such as a Kubernetes Secret mounted as a file. | | `privateKeyPassphrase` | `properties[private_key_pwd]: "{{?privateKeyPassphrase}}"` | The passphrase of an encrypted key. `format: password`. | | `password` (now optional) | `password: "{{password:}}"` (was `"{{password}}"`) | Unchanged when it is set. | - **When a key is set, the driver chooses key-pair login by itself.** With no `authenticator` set, it uses `SNOWFLAKE_JWT` whenever a private key property is present, and it then does not send the password. - **Why `{{password:}}` and not `{{?password}}`:** an optional placeholder that resolves to nothing skips the setter, so the data source's password stays `null`. The data source then refuses to connect before the driver even looks at the key: "Cannot create connection because password is missing in DataSource properties". This happened in a test with `{{?password}}`. - With an empty default, the setter receives `""`. For key login, the empty password is never sent. - With neither a password nor a key, the driver fails with `Missing password.` before any request. - **The key options use `{{?x}}`:** when they are unset, the setter is skipped, so no key property is put into the map. That matters here because the driver treats an empty string as a key. The unset case below proves it: the password login request is identical to `main`'s. - **The key is text, as asked:** `private_key_base64` is the driver's only text form. It is the PEM file encoded in base64; the PEM text itself fails with `Private key provided is invalid or not supported`. The file option covers a Secret mounted as a file. - **Encrypted keys:** driver 4.x decrypts with its bundled Bouncy Castle by default. A PKCS#8 key encrypted with AES-256-CBC, as Snowflake's guide makes it with `openssl pkcs8 -topk8 -v2 aes-256-cbc`, worked from both options. - **No `pattern:`:** none of the options goes into a URI. The bean receives them directly. - **Descriptions:** - The "Good to know" paragraph of both Kamelets says how to log in, and that a SERVICE user cannot use a password. - The `password` description gives the `Missing password` error. - The option descriptions name the failure cases found in testing. - Both partial pages have an "Authentication methods" section and an "Example with a Key Pair". ### Verification There is no local Snowflake. Instead, I captured the driver's login request with a stand-in: a small Python HTTP server that writes each `POST /session/v1/login-request` body (gunzipped) to a file and answers with Snowflake's login-failure JSON. - **Pointing the driver at it:** `instanceUrl` was `localhost:18099/?ssl=off&account=MYACCOUNT`. These are driver connect-string parameters, used for the test only. - **Keys:** two RSA 2048 keys made with the commands from Snowflake's guide, one unencrypted (`-nocrypt`) and one encrypted with `-v2 aes-256-cbc`. - **Checking each JWT:** decode its claims, compare the `SHA256:` fingerprint in `iss` with the fingerprint of the matching `.pub` file (SHA-256 of the DER public key, as Snowflake computes it), and check the RS256 signature with `openssl dgst -verify`. Tested with Camel JBang 4.24.0-SNAPSHOT, `camel run ... --local-kamelet-dir`: | Case | Kamelet | Result | |---|---|---| | `password` only, `main` and this branch | sink, source | Login JSON identical apart from the driver's cloud-platform probe timings: `PASSWORD` sent, no `AUTHENTICATOR`. `camel get endpoint` shows the same `local-sql-snowflake-*-1://...?dataSource=#bean:dsBean-2` URIs on both | | `privateKey` (base64 of unencrypted PEM), no password | sink, source | `AUTHENTICATOR=SNOWFLAKE_JWT`, no `PASSWORD`. The `TOKEN` is an RS256 JWT, `sub=MYACCOUNT.MY_USER`, `iss=MYACCOUNT.MY_USER.SHA256:K6xv…`, which matches `rsa_key.pub`. Signature `Verified OK` with that key, `Verification failure` with the other key | | `privateKeyFile` (unencrypted PEM) | sink, source | The same: JWT login, signature verified with `rsa_key.pub` | | `privateKey` (base64 of encrypted PEM) + `privateKeyPassphrase` | sink, source | JWT login. `iss` fingerprint `SHA256:5358…` matches `rsa_key_enc.pub`, signature verified | | `privateKeyFile` (encrypted PEM) + `privateKeyPassphrase` | sink, source | The same, verified with `rsa_key_enc.pub` | | `privateKey` set in the route's `parameters` from a property, value containing `+`, `/` and `=` | sink | JWT login, signature verified: the base64 value reaches the driver intact | | `privateKey` and `password` both set | sink | JWT login, and the password is not sent | | Neither a password nor a key | sink, source | Fails with `Missing password.`; no request reaches the server | | `privateKey` and `privateKeyFile` both set | sink | Fails with `Cannot have both private key file and private key base64 string value` | | `privateKey` set to the PEM text, not base64 | sink | Fails with `Private key provided is invalid or not supported`; no request | | Encrypted key, wrong passphrase | sink | Fails with `Private key provided is invalid or not supported: ... Error finalising cipher`; no request | | Encrypted key, no passphrase | sink | Fails with a `NullPointerException` from the driver (`privateKeyPwd` is null); no request | | `privateKeyFile` that does not exist | sink | Fails with `Invalid parameter value null for parameter type {1}.`; no request | `./mvnw clean verify -DskipTests` and then `./mvnw clean verify` passed from the root. Before building, the library copies of both Kamelets were refreshed with `./mvnw -pl library/camel-kamelets resources:copy-resources@copy-resource-one`. The build regenerated `kamelets-index.json`. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
