Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add support for secret rotation using RSA for snowflake users
adilson6794f30ffeb8
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.tsindex f529032576..7765a4527e 100644--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts@@ -21,6 +21,7 @@ import { registerOracleDBCredentialsRotationRouter } from "./oracledb-credentialimport { registerPostgresCredentialsRotationRouter } from "./postgres-credentials-rotation-router";import { registerRedisCredentialsRotationRouter } from "./redis-credentials-rotation-router";import { registerSalesforceOauthCredentialsRotationRouter } from "./salesforce-oauth-credentials-rotation-router";+import { registerSnowflakeUserKeyPairRotationRouter } from "./snowflake-user-key-pair-rotation-router";import { registerSupabaseApiKeyRotationRouter } from "./supabase-api-key-rotation-router";import { registerUnixLinuxLocalAccountRotationRouter } from "./unix-linux-local-account-rotation-router";import { registerWindowsLocalAccountRotationRouter } from "./windows-local-account-rotation-router";@@ -54,5 +55,6 @@ export const SECRET_ROTATION_REGISTER_ROUTER_MAP: Record<[SecretRotation.SalesforceOauthCredentials]: registerSalesforceOauthCredentialsRotationRouter,[SecretRotation.DatadogApplicationKeySecret]: registerDatadogApplicationKeySecretRotationRouter,[SecretRotation.ConvexAccessKey]: registerConvexAccessKeyRotationRouter,- [SecretRotation.FireworksApiKey]: registerFireworksApiKeyRotationRouter+ [SecretRotation.FireworksApiKey]: registerFireworksApiKeyRotationRouter,+ [SecretRotation.SnowflakeUserKeyPair]: registerSnowflakeUserKeyPairRotationRouter};diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.tsindex a7fc88177f..18eb0d0af0 100644--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts@@ -23,6 +23,7 @@ import { PostgresCredentialsRotationListItemSchema } from "@app/ee/services/secrimport { RedisCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/redis-credentials";import { SalesforceOauthCredentialsRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/salesforce-oauth-credentials";import { SecretRotationV2Schema } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema";+import { SnowflakeUserKeyPairRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/snowflake-user-key-pair";import { SupabaseApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/supabase-api-key";import { UnixLinuxLocalAccountRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/unix-linux-local-account-rotation";import { WindowsLocalAccountRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/windows-local-account-rotation";@@ -55,7 +56,8 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [SalesforceOauthCredentialsRotationListItemSchema,DatadogApplicationKeySecretRotationListItemSchema,ConvexAccessKeyRotationListItemSchema,- FireworksApiKeyRotationListItemSchema+ FireworksApiKeyRotationListItemSchema,+ SnowflakeUserKeyPairRotationListItemSchema]);export const registerSecretRotationV2Router = async (server: FastifyZodProvider) => {diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/snowflake-user-key-pair-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/snowflake-user-key-pair-rotation-router.tsnew file mode 100644index 0000000000..d744ea5eb6--- /dev/null+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/snowflake-user-key-pair-rotation-router.ts@@ -0,0 +1,19 @@+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";+import {+ CreateSnowflakeUserKeyPairRotationSchema,+ SnowflakeUserKeyPairRotationGeneratedCredentialsSchema,+ SnowflakeUserKeyPairRotationSchema,+ UpdateSnowflakeUserKeyPairRotationSchema+} from "@app/ee/services/secret-rotation-v2/snowflake-user-key-pair";++import { registerSecretRotationEndpoints } from "./secret-rotation-v2-endpoints";++export const registerSnowflakeUserKeyPairRotationRouter = async (server: FastifyZodProvider) =>+ registerSecretRotationEndpoints({+ type: SecretRotation.SnowflakeUserKeyPair,+ server,+ responseSchema: SnowflakeUserKeyPairRotationSchema,+ createSchema: CreateSnowflakeUserKeyPairRotationSchema,+ updateSchema: UpdateSnowflakeUserKeyPairRotationSchema,+ generatedCredentialsSchema: SnowflakeUserKeyPairRotationGeneratedCredentialsSchema+ });diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.tsindex 58b8b9eb37..60b88543bd 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts@@ -22,7 +22,8 @@ export enum SecretRotation {SalesforceOauthCredentials = "salesforce-oauth-credentials",DatadogApplicationKeySecret = "datadog-application-key-secret",ConvexAccessKey = "convex-access-key",- FireworksApiKey = "fireworks-api-key"+ FireworksApiKey = "fireworks-api-key",+ SnowflakeUserKeyPair = "snowflake-user-key-pair"}export enum SecretRotationStatus {diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.tsindex cebf16adc3..e92b7cc895 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts@@ -41,6 +41,7 @@ import {TSecretRotationV2Raw,TUpdateSecretRotationV2DTO} from "./secret-rotation-v2-types";+import { SNOWFLAKE_USER_KEY_PAIR_ROTATION_LIST_OPTION, TSnowflakeUserKeyPairRotation } from "./snowflake-user-key-pair";import { SUPABASE_API_KEY_ROTATION_LIST_OPTION, TSupabaseApiKeyRotation } from "./supabase-api-key";import {TUnixLinuxLocalAccountRotation,@@ -75,7 +76,8 @@ const SECRET_ROTATION_LIST_OPTIONS: Record<SecretRotation, TSecretRotationV2List[SecretRotation.SalesforceOauthCredentials]: SALESFORCE_OAUTH_CREDENTIALS_ROTATION_LIST_OPTION,[SecretRotation.DatadogApplicationKeySecret]: DATADOG_APPLICATION_KEY_SECRET_ROTATION_LIST_OPTION,[SecretRotation.ConvexAccessKey]: CONVEX_ACCESS_KEY_ROTATION_LIST_OPTION,- [SecretRotation.FireworksApiKey]: FIREWORKS_API_KEY_ROTATION_LIST_OPTION+ [SecretRotation.FireworksApiKey]: FIREWORKS_API_KEY_ROTATION_LIST_OPTION,+ [SecretRotation.SnowflakeUserKeyPair]: SNOWFLAKE_USER_KEY_PAIR_ROTATION_LIST_OPTION};export const listSecretRotationOptions = () => {@@ -409,6 +411,17 @@ export const throwOnImmutableParameterUpdate = (throw new BadRequestError({ message: "Cannot update project ID" });}break;+ case SecretRotation.SnowflakeUserKeyPair:+ if (+ haveUnequalProperties(+ updatePayload.parameters as TSnowflakeUserKeyPairRotation["parameters"],+ secretRotation.parameters as TSnowflakeUserKeyPairRotation["parameters"],+ ["username"]+ )+ ) {+ throw new BadRequestError({ message: "Cannot update username" });+ }+ break;default:// do nothing}diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.tsindex 16d9a4d421..9f58a96033 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts@@ -25,7 +25,8 @@ export const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {[SecretRotation.SalesforceOauthCredentials]: "Salesforce OAuth Credentials",[SecretRotation.DatadogApplicationKeySecret]: "Datadog Application Key",[SecretRotation.ConvexAccessKey]: "Convex Access Key",- [SecretRotation.FireworksApiKey]: "Fireworks Secret"+ [SecretRotation.FireworksApiKey]: "Fireworks Secret",+ [SecretRotation.SnowflakeUserKeyPair]: "Snowflake User Key Pair"};export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnection> = {@@ -52,5 +53,6 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.SalesforceOauthCredentials]: AppConnection.Salesforce,[SecretRotation.DatadogApplicationKeySecret]: AppConnection.Datadog,[SecretRotation.ConvexAccessKey]: AppConnection.Convex,- [SecretRotation.FireworksApiKey]: AppConnection.Fireworks+ [SecretRotation.FireworksApiKey]: AppConnection.Fireworks,+ [SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake};diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.tsindex a1f3de2957..086ff036c4 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts@@ -61,6 +61,7 @@ import {TUpdateSecretRotationV2DTO} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";import { sqlCredentialsRotationFactory } from "@app/ee/services/secret-rotation-v2/shared/sql-credentials";+import { snowflakeUserKeyPairRotationFactory } from "@app/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-fns";import { TSecretSnapshotServiceFactory } from "@app/ee/services/secret-snapshot/secret-snapshot-service";import { KeyStorePrefixes, PgSqlLock, TKeyStoreFactory } from "@app/keystore/keystore";import { getConfig } from "@app/lib/config/env";@@ -211,7 +212,8 @@ const SECRET_ROTATION_FACTORY_MAP: Record<SecretRotation, TRotationFactoryImplem[SecretRotation.DatadogApplicationKeySecret]:datadogApplicationKeySecretRotationFactory as TRotationFactoryImplementation,[SecretRotation.ConvexAccessKey]: convexAccessKeyRotationFactory as TRotationFactoryImplementation,- [SecretRotation.FireworksApiKey]: fireworksApiKeyRotationFactory as TRotationFactoryImplementation+ [SecretRotation.FireworksApiKey]: fireworksApiKeyRotationFactory as TRotationFactoryImplementation,+ [SecretRotation.SnowflakeUserKeyPair]: snowflakeUserKeyPairRotationFactory as TRotationFactoryImplementation};export const secretRotationV2ServiceFactory = ({diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.tsindex b73f2a21de..1331dac045 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts@@ -153,6 +153,13 @@ import {} from "./salesforce-oauth-credentials";import { TSecretRotationV2DALFactory } from "./secret-rotation-v2-dal";import { SecretRotation } from "./secret-rotation-v2-enums";+import {+ TSnowflakeUserKeyPairRotation,+ TSnowflakeUserKeyPairRotationGeneratedCredentials,+ TSnowflakeUserKeyPairRotationInput,+ TSnowflakeUserKeyPairRotationListItem,+ TSnowflakeUserKeyPairRotationWithConnection+} from "./snowflake-user-key-pair";import {TSupabaseApiKeyRotation,TSupabaseApiKeyRotationGeneratedCredentials,@@ -199,7 +206,8 @@ export type TSecretRotationV2 =| TSalesforceOauthCredentialsRotation| TDatadogApplicationKeySecretRotation| TConvexAccessKeyRotation- | TFireworksApiKeyRotation;+ | TFireworksApiKeyRotation+ | TSnowflakeUserKeyPairRotation;export type TSecretRotationV2WithConnection =| TPostgresCredentialsRotationWithConnection@@ -225,7 +233,8 @@ export type TSecretRotationV2WithConnection =| TSalesforceOauthCredentialsRotationWithConnection| TDatadogApplicationKeySecretRotationWithConnection| TConvexAccessKeyRotationWithConnection- | TFireworksApiKeyRotationWithConnection;+ | TFireworksApiKeyRotationWithConnection+ | TSnowflakeUserKeyPairRotationWithConnection;export type TSecretRotationV2GeneratedCredentials =| TSqlCredentialsRotationGeneratedCredentials@@ -247,7 +256,8 @@ export type TSecretRotationV2GeneratedCredentials =| TSalesforceOauthCredentialsRotationGeneratedCredentials| TDatadogApplicationKeySecretRotationGeneratedCredentials| TConvexAccessKeyRotationGeneratedCredentials- | TFireworksApiKeyRotationGeneratedCredentials;+ | TFireworksApiKeyRotationGeneratedCredentials+ | TSnowflakeUserKeyPairRotationGeneratedCredentials;export type TSecretRotationV2Input =| TPostgresCredentialsRotationInput@@ -273,7 +283,8 @@ export type TSecretRotationV2Input =| TSalesforceOauthCredentialsRotationInput| TDatadogApplicationKeySecretRotationInput| TConvexAccessKeyRotationInput- | TFireworksApiKeyRotationInput;+ | TFireworksApiKeyRotationInput+ | TSnowflakeUserKeyPairRotationInput;export type TSecretRotationV2ListItem =| TPostgresCredentialsRotationListItem@@ -299,7 +310,8 @@ export type TSecretRotationV2ListItem =| TSalesforceOauthCredentialsRotationListItem| TDatadogApplicationKeySecretRotationListItem| TConvexAccessKeyRotationListItem- | TFireworksApiKeyRotationListItem;+ | TFireworksApiKeyRotationListItem+ | TSnowflakeUserKeyPairRotationListItem;export type TSecretRotationV2TemporaryParameters =| TLdapPasswordRotationInput["temporaryParameters"]diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.tsindex 75c9360080..170b360526 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts@@ -24,6 +24,7 @@ import { ConvexAccessKeyRotationSchema } from "./convex-access-key";import { DbtServiceTokenRotationSchema } from "./dbt-service-token";import { FireworksApiKeyRotationSchema } from "./fireworks-api-key";import { HpIloRotationSchema } from "./hp-ilo-rotation";+import { SnowflakeUserKeyPairRotationSchema } from "./snowflake-user-key-pair";import { SupabaseApiKeyRotationSchema } from "./supabase-api-key";export const SecretRotationV2Schema = z.discriminatedUnion("type", [@@ -50,5 +51,6 @@ export const SecretRotationV2Schema = z.discriminatedUnion("type", [SalesforceOauthCredentialsRotationSchema,DatadogApplicationKeySecretRotationSchema,ConvexAccessKeyRotationSchema,- FireworksApiKeyRotationSchema+ FireworksApiKeyRotationSchema,+ SnowflakeUserKeyPairRotationSchema]);diff --git a/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/index.ts b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/index.tsnew file mode 100644index 0000000000..2294a9372f--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/index.ts@@ -0,0 +1,3 @@+export * from "./snowflake-user-key-pair-rotation-constants";+export * from "./snowflake-user-key-pair-rotation-schemas";+export * from "./snowflake-user-key-pair-rotation-types";diff --git a/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-constants.tsnew file mode 100644index 0000000000..eae9dc3c70--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-constants.ts@@ -0,0 +1,15 @@+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";+import { TSecretRotationV2ListItem } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++export const SNOWFLAKE_USER_KEY_PAIR_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {+ name: "Snowflake User Key Pair",+ type: SecretRotation.SnowflakeUserKeyPair,+ connection: AppConnection.Snowflake,+ template: {+ secretsMapping: {+ privateKey: "SNOWFLAKE_PRIVATE_KEY",+ publicKey: "SNOWFLAKE_PUBLIC_KEY"+ }+ }+};diff --git a/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-fns.tsnew file mode 100644index 0000000000..9dfb175944--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-fns.ts@@ -0,0 +1,198 @@+/* eslint-disable no-await-in-loop */+import snowflake from "snowflake-sdk";++import {+ TRotationFactory,+ TRotationFactoryCheckActiveCredentials,+ TRotationFactoryGetSecretsPayload,+ TRotationFactoryIssueCredentials,+ TRotationFactoryRevokeCredentials,+ TRotationFactoryRotateCredentials+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";+import { crypto } from "@app/lib/crypto/cryptography";+import { BadRequestError } from "@app/lib/errors";+import {+ executeSnowflakeSql,+ quoteSnowflakeIdent,+ sanitizeSnowflakeError,+ withSnowflakeClient+} from "@app/services/app-connection/snowflake";++import {+ TSnowflakeUserKeyPairRotationGeneratedCredentials,+ TSnowflakeUserKeyPairRotationWithConnection+} from "./snowflake-user-key-pair-rotation-types";++const RSA_MODULUS_LENGTH = 2048;++// Snowflake exposes two public-key slots per user. index 0 -> RSA_PUBLIC_KEY, index 1 -> RSA_PUBLIC_KEY_2.+const RSA_PUBLIC_KEY_SLOTS = ["RSA_PUBLIC_KEY", "RSA_PUBLIC_KEY_2"] as const;+type TSnowflakePublicKeySlot = (typeof RSA_PUBLIC_KEY_SLOTS)[number];++const slotForIndex = (index: number): TSnowflakePublicKeySlot => (index === 0 ? "RSA_PUBLIC_KEY" : "RSA_PUBLIC_KEY_2");++const generateRsaKeyPair = () =>+ new Promise<{ privateKey: string; publicKey: string }>((resolve, reject) => {+ crypto.nativeCrypto.generateKeyPair(+ "rsa",+ {+ modulusLength: RSA_MODULUS_LENGTH,+ publicKeyEncoding: { type: "spki", format: "pem" },+ privateKeyEncoding: { type: "pkcs8", format: "pem" }+ },+ (err, publicKey, privateKey) => {+ if (err) reject(err);+ else resolve({ publicKey, privateKey });+ }+ );+ });++// Snowflake's ALTER USER ... SET RSA_PUBLIC_KEY expects the base64 body only (no PEM delimiters/newlines).+const toSnowflakePublicKeyBody = (spkiPem: string) =>+ spkiPem+ .replace(/-----BEGIN PUBLIC KEY-----/g, "")+ .replace(/-----END PUBLIC KEY-----/g, "")+ .replace(/\s+/g, "");++// Snowflake stores the public key fingerprint as SHA256:<base64(sha256(spki-DER))>.+const computeFingerprint = (privateKeyPem: string) => {+ const privateKeyObj = crypto.nativeCrypto.createPrivateKey({ key: privateKeyPem, format: "pem", type: "pkcs8" });+ const publicKeyDer = crypto.nativeCrypto.createPublicKey(privateKeyObj).export({ type: "spki", format: "der" });+ return `SHA256:${crypto.nativeCrypto.createHash("sha256").update(publicKeyDer).digest("base64")}`;+};++export const snowflakeUserKeyPairRotationFactory: TRotationFactory<+ TSnowflakeUserKeyPairRotationWithConnection,+ TSnowflakeUserKeyPairRotationGeneratedCredentials+> = (secretRotation) => {+ const {+ connection,+ parameters: { username },+ activeIndex,+ secretsMapping+ } = secretRotation;++ const runSnowflake = async <T>(fn: (client: snowflake.Connection) => Promise<T>, errorPrefix: string): Promise<T> => {+ try {+ return await withSnowflakeClient(connection.credentials, fn);+ } catch (error) {+ throw sanitizeSnowflakeError(error, connection.credentials, errorPrefix);+ }+ };++ const readFingerprints = async (client: snowflake.Connection) => {+ // DESC USER returns one row per user property with `property`/`value` columns. Snowflake reports+ // these column names in lowercase, but we read them case-insensitively to be safe across drivers.+ const rows = await executeSnowflakeSql<Record<string, unknown>>(+ client,+ `DESC USER ${quoteSnowflakeIdent(username)}`+ );++ const fingerprints: Partial<Record<TSnowflakePublicKeySlot, string>> = {};+ for (const row of rows) {+ const property = String(row.property ?? row.PROPERTY ?? "").toUpperCase();+ const value = (row.value ?? row.VALUE) as string | null | undefined;+ if (value) {+ if (property === "RSA_PUBLIC_KEY_FP") fingerprints.RSA_PUBLIC_KEY = value;+ else if (property === "RSA_PUBLIC_KEY_2_FP") fingerprints.RSA_PUBLIC_KEY_2 = value;+ }+ }+ return fingerprints;+ };++ // Assign the public key to the given slot, then confirm Snowflake stored it by comparing fingerprints.+ const setPublicKeyForSlot = async (+ slot: TSnowflakePublicKeySlot,+ keyPair: { privateKey: string; publicKey: string }+ ) => {+ const expectedFingerprint = computeFingerprint(keyPair.privateKey);++ const fingerprints = await runSnowflake(async (client) => {+ await executeSnowflakeSql(+ client,+ `ALTER USER ${quoteSnowflakeIdent(username)} SET ${slot} = '${toSnowflakePublicKeyBody(keyPair.publicKey)}'`+ );+ return readFingerprints(client);+ }, `Failed to set RSA public key for Snowflake user "${username}"`);++ if (fingerprints[slot] !== expectedFingerprint) {+ throw new BadRequestError({+ message: `Failed to verify the RSA public key on Snowflake user "${username}" (${slot}). Ensure the connection's role has privileges to alter this user.`+ });+ }+ };++ const issueCredentials: TRotationFactoryIssueCredentials<TSnowflakeUserKeyPairRotationGeneratedCredentials> = async (+ callback+ ) => {+ // On creation the first credential always occupies slot 0 (activeIndex defaults to 0).+ const keyPair = await generateRsaKeyPair();+ await setPublicKeyForSlot(slotForIndex(0), keyPair);+ return callback(keyPair);+ };++ const rotateCredentials: TRotationFactoryRotateCredentials<+ TSnowflakeUserKeyPairRotationGeneratedCredentials+ > = async (_credentialsToRevoke, callback) => {+ // Write the new key to the currently-inactive slot. SET overwrites whatever key was there+ // (invalidating the credential from two rotations ago), while the active slot's key remains+ // valid as the retired credential - Snowflake's documented no-downtime dual-key rotation.+ const inactiveIndex = (activeIndex + 1) % RSA_PUBLIC_KEY_SLOTS.length;+ const keyPair = await generateRsaKeyPair();+ await setPublicKeyForSlot(slotForIndex(inactiveIndex), keyPair);+ return callback(keyPair);+ };++ const revokeCredentials: TRotationFactoryRevokeCredentials<+ TSnowflakeUserKeyPairRotationGeneratedCredentials+ > = async (credentialsToRevoke, callback) => {+ if (!credentialsToRevoke?.length) return callback();++ // Only unset slots holding a key Infisical generated, so we never remove a key set outside this rotation.+ const managedFingerprints = new Set(credentialsToRevoke.map((cred) => computeFingerprint(cred.privateKey)));++ await runSnowflake(async (client) => {+ const fingerprints = await readFingerprints(client);+ for (const slot of RSA_PUBLIC_KEY_SLOTS) {+ const slotFingerprint = fingerprints[slot];+ if (slotFingerprint && managedFingerprints.has(slotFingerprint)) {+ await executeSnowflakeSql(client, `ALTER USER ${quoteSnowflakeIdent(username)} UNSET ${slot}`);+ }+ }+ }, `Failed to revoke RSA public keys for Snowflake user "${username}"`);++ return callback();+ };++ const getSecretsPayload: TRotationFactoryGetSecretsPayload<TSnowflakeUserKeyPairRotationGeneratedCredentials> = (+ generatedCredentials+ ) => [+ { key: secretsMapping.privateKey, value: generatedCredentials.privateKey },+ { key: secretsMapping.publicKey, value: generatedCredentials.publicKey }+ ];++ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TSnowflakeUserKeyPairRotationGeneratedCredentials+ > = async (activeCredentials) => {+ const expectedFingerprint = computeFingerprint(activeCredentials.privateKey);+ const fingerprints = await runSnowflake(+ async (client) => readFingerprints(client),+ `Failed to verify RSA public key for Snowflake user "${username}"`+ );++ const isPresent = RSA_PUBLIC_KEY_SLOTS.some((slot) => fingerprints[slot] === expectedFingerprint);+ if (!isPresent) {+ throw new BadRequestError({+ message: `The active key pair is no longer present on Snowflake user "${username}".`+ });+ }+ };++ return {+ issueCredentials,+ revokeCredentials,+ rotateCredentials,+ getSecretsPayload,+ checkActiveCredentials+ };+};diff --git a/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-schemas.tsnew file mode 100644index 0000000000..449d216e0f--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-schemas.ts@@ -0,0 +1,67 @@+import { z } from "zod";++import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";+import {+ BaseCreateSecretRotationSchema,+ BaseSecretRotationSchema,+ BaseUpdateSecretRotationSchema+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";+import { SecretRotations } from "@app/lib/api-docs";+import { SecretNameSchema } from "@app/server/lib/schemas";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++export const SnowflakeUserKeyPairRotationGeneratedCredentialsSchema = z+ .object({+ privateKey: z.string(),+ publicKey: z.string()+ })+ .array()+ .min(1)+ .max(2);++const SnowflakeUserKeyPairRotationParametersSchema = z.object({+ username: z+ .string()+ .trim()+ .min(1, "User Required")+ .describe(SecretRotations.PARAMETERS.SNOWFLAKE_USER_KEY_PAIR.username)+});++const SnowflakeUserKeyPairRotationSecretsMappingSchema = z.object({+ privateKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.SNOWFLAKE_USER_KEY_PAIR.privateKey),+ publicKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.SNOWFLAKE_USER_KEY_PAIR.publicKey)+});++export const SnowflakeUserKeyPairRotationTemplateSchema = z.object({+ secretsMapping: z.object({+ privateKey: z.string(),+ publicKey: z.string()+ })+});++export const SnowflakeUserKeyPairRotationSchema = BaseSecretRotationSchema(SecretRotation.SnowflakeUserKeyPair).extend({+ type: z.literal(SecretRotation.SnowflakeUserKeyPair),+ parameters: SnowflakeUserKeyPairRotationParametersSchema,+ secretsMapping: SnowflakeUserKeyPairRotationSecretsMappingSchema+});++export const CreateSnowflakeUserKeyPairRotationSchema = BaseCreateSecretRotationSchema(+ SecretRotation.SnowflakeUserKeyPair+).extend({+ parameters: SnowflakeUserKeyPairRotationParametersSchema,+ secretsMapping: SnowflakeUserKeyPairRotationSecretsMappingSchema+});++export const UpdateSnowflakeUserKeyPairRotationSchema = BaseUpdateSecretRotationSchema(+ SecretRotation.SnowflakeUserKeyPair+).extend({+ parameters: SnowflakeUserKeyPairRotationParametersSchema.optional(),+ secretsMapping: SnowflakeUserKeyPairRotationSecretsMappingSchema.optional()+});++export const SnowflakeUserKeyPairRotationListItemSchema = z.object({+ name: z.literal("Snowflake User Key Pair"),+ connection: z.literal(AppConnection.Snowflake),+ type: z.literal(SecretRotation.SnowflakeUserKeyPair),+ template: SnowflakeUserKeyPairRotationTemplateSchema+});diff --git a/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-types.tsnew file mode 100644index 0000000000..8550e35822--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/snowflake-user-key-pair/snowflake-user-key-pair-rotation-types.ts@@ -0,0 +1,24 @@+import { z } from "zod";++import { TSnowflakeConnection } from "@app/services/app-connection/snowflake";++import {+ CreateSnowflakeUserKeyPairRotationSchema,+ SnowflakeUserKeyPairRotationGeneratedCredentialsSchema,+ SnowflakeUserKeyPairRotationListItemSchema,+ SnowflakeUserKeyPairRotationSchema+} from "./snowflake-user-key-pair-rotation-schemas";++export type TSnowflakeUserKeyPairRotation = z.infer<typeof SnowflakeUserKeyPairRotationSchema>;++export type TSnowflakeUserKeyPairRotationInput = z.infer<typeof CreateSnowflakeUserKeyPairRotationSchema>;++export type TSnowflakeUserKeyPairRotationListItem = z.infer<typeof SnowflakeUserKeyPairRotationListItemSchema>;++export type TSnowflakeUserKeyPairRotationWithConnection = TSnowflakeUserKeyPairRotation & {+ connection: TSnowflakeConnection;+};++export type TSnowflakeUserKeyPairRotationGeneratedCredentials = z.infer<+ typeof SnowflakeUserKeyPairRotationGeneratedCredentialsSchema+>;diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex bdab71e86e..4632759888 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3564,6 +3564,9 @@ export const SecretRotations = {},FIREWORKS_API_KEY: {serviceAccountUserId: "The user ID of the Fireworks service account to create the API key for."+ },+ SNOWFLAKE_USER_KEY_PAIR: {+ username: "The Snowflake user whose RSA key pair will be rotated."}},SECRETS_MAPPING: {@@ -3647,6 +3650,10 @@ export const SecretRotations = {},FIREWORKS_API_KEY: {apiKey: "The name of the secret that the rotated Fireworks API key will be mapped to."+ },+ SNOWFLAKE_USER_KEY_PAIR: {+ privateKey: "The name of the secret that the generated RSA private key (PKCS#8 PEM) will be mapped to.",+ publicKey: "The name of the secret that the generated RSA public key (SPKI PEM) will be mapped to."}}};diff --git a/backend/src/server/routes/v1/app-connection-routers/snowflake-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/snowflake-connection-router.tsindex f8a3299bbd..500f3c4437 100644--- a/backend/src/server/routes/v1/app-connection-routers/snowflake-connection-router.ts+++ b/backend/src/server/routes/v1/app-connection-routers/snowflake-connection-router.ts@@ -82,4 +82,31 @@ export const registerSnowflakeConnectionRouter = async (server: FastifyZodProvidreturn { schemas };}});++ server.route({+ method: "GET",+ url: `/:connectionId/users`,+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: "listSnowflakeUsers",+ params: z.object({+ connectionId: z.string().uuid()+ }),+ response: {+ 200: z.object({+ users: z.object({ name: z.string() }).array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT]),+ handler: async (req) => {+ const { connectionId } = req.params;++ const users = await server.services.appConnection.snowflake.listUsers(connectionId, req.permission);++ return { users };+ }+ });};diff --git a/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts b/backend/src/services/app-connection/snowflake/snowflake-connection-fns.tsindex 15cb076da1..0e651d29fd 100644--- a/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts+++ b/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts@@ -12,7 +12,7 @@ const noop = () => {};const SNOWFLAKE_EXCLUDED_DATABASES = new Set(["SNOWFLAKE", "SNOWFLAKE_SAMPLE_DATA"]);const SNOWFLAKE_EXCLUDED_SCHEMAS = new Set(["INFORMATION_SCHEMA"]);-export const SNOWFLAKE_SHOW_PAGE_SIZE = 1000;+export const SNOWFLAKE_SHOW_PAGE_SIZE = 100;const escapeSnowflakeStringLiteral = (value: string) => value.replace(/'/g, "''");@@ -126,7 +126,7 @@ export const withSnowflakeClient = async <T>(}};-const sanitizeSnowflakeError = (+export const sanitizeSnowflakeError = (err: unknown,credentials: TSnowflakeConnection["credentials"],errorPrefix: string@@ -191,3 +191,21 @@ export const listSnowflakeSchemas = async (credentials: TSnowflakeConnection["crthrow sanitizeSnowflakeError(err, credentials, "Unable to list Snowflake schemas");}};++export const listSnowflakeUsers = async (credentials: TSnowflakeConnection["credentials"]) => {+ try {+ return await withSnowflakeClient(credentials, async (client) => {+ const users: { name: string }[] = [];+ for await (const page of paginateSnowflakeShow<{ name?: string }>(client, "SHOW USERS")) {+ for (const row of page) {+ // eslint-disable-next-line no-continue+ if (!row.name) continue;+ users.push({ name: row.name });+ }+ }+ return users;+ });+ } catch (err) {+ throw sanitizeSnowflakeError(err, credentials, "Unable to list Snowflake users");+ }+};diff --git a/backend/src/services/app-connection/snowflake/snowflake-connection-service.ts b/backend/src/services/app-connection/snowflake/snowflake-connection-service.tsindex 5b09bd648c..8e03aa2a94 100644--- a/backend/src/services/app-connection/snowflake/snowflake-connection-service.ts+++ b/backend/src/services/app-connection/snowflake/snowflake-connection-service.ts@@ -2,7 +2,8 @@ import { OrgServiceActor } from "@app/lib/types";import { AppConnection } from "@app/services/app-connection/app-connection-enums";import {listSnowflakeDatabases,- listSnowflakeSchemas+ listSnowflakeSchemas,+ listSnowflakeUsers} from "@app/services/app-connection/snowflake/snowflake-connection-fns";import { TSnowflakeConnection } from "@app/services/app-connection/snowflake/snowflake-connection-types";@@ -23,8 +24,14 @@ export const snowflakeConnectionService = (getAppConnection: TGetAppConnectionFureturn listSnowflakeSchemas(appConnection.credentials, database);};+ const listUsers = async (connectionId: string, actor: OrgServiceActor) => {+ const appConnection = await getAppConnection(AppConnection.Snowflake, connectionId, actor);+ return listSnowflakeUsers(appConnection.credentials);+ };+return {listDatabases,- listSchemas+ listSchemas,+ listUsers};};diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsxindex b71e5e393e..9d218450c7 100644--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx@@ -34,6 +34,7 @@ import { ViewOpenAIServiceAccountRotationGeneratedCredentials } from "./ViewOpenimport { ViewOpenRouterApiKeyRotationGeneratedCredentials } from "./ViewOpenRouterApiKeyRotationGeneratedCredentials";import { ViewRedisCredentialsRotationGeneratedCredentials } from "./ViewRedisCredentialsRotationGeneratedCredentials";import { ViewSalesforceOauthCredentialsRotationGeneratedCredentials } from "./ViewSalesforceOauthCredentialsRotationGeneratedCredentials";+import { ViewSnowflakeUserKeyPairRotationGeneratedCredentials } from "./ViewSnowflakeUserKeyPairRotationGeneratedCredentials";import { ViewSupabaseApiKeyRotationGeneratedCredentials } from "./ViewSupabaseApiKeyRotationGeneratedCredentials";import { ViewUnixLinuxLocalAccountRotationGeneratedCredentials } from "./ViewUnixLinuxLocalAccountRotationGeneratedCredentials";import { ViewWindowsLocalAccountRotationGeneratedCredentials } from "./ViewWindowsLocalAccountRotationGeneratedCredentials";@@ -220,6 +221,13 @@ const Content = ({ secretRotation }: ContentProps) => {/>);break;+ case SecretRotation.SnowflakeUserKeyPair:+ Component = (+ <ViewSnowflakeUserKeyPairRotationGeneratedCredentials+ generatedCredentialsResponse={generatedCredentialsResponse}+ />+ );+ break;default:throw new Error("Unhandled View Generated Credential Rotation Type");}diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSnowflakeUserKeyPairRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSnowflakeUserKeyPairRotationGeneratedCredentials.tsxnew file mode 100644index 0000000000..b25e93cd64--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSnowflakeUserKeyPairRotationGeneratedCredentials.tsx@@ -0,0 +1,38 @@+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";+import { TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/snowflake-user-key-pair-rotation";++import { ViewRotationGeneratedCredentialsDisplay } from "./shared";++type Props = {+ generatedCredentialsResponse: TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse;+};++export const ViewSnowflakeUserKeyPairRotationGeneratedCredentials = ({+ generatedCredentialsResponse: { generatedCredentials, activeIndex }+}: Props) => {+ const inactiveIndex = activeIndex === 0 ? 1 : 0;++ const activeCredentials = generatedCredentials[activeIndex];+ const inactiveCredentials = generatedCredentials[inactiveIndex];++ return (+ <ViewRotationGeneratedCredentialsDisplay+ activeCredentials={+ <>+ <CredentialDisplay label="Public Key">{activeCredentials?.publicKey}</CredentialDisplay>+ <CredentialDisplay isSensitive label="Private Key">+ {activeCredentials?.privateKey}+ </CredentialDisplay>+ </>+ }+ inactiveCredentials={+ <>+ <CredentialDisplay label="Public Key">{inactiveCredentials?.publicKey}</CredentialDisplay>+ <CredentialDisplay isSensitive label="Private Key">+ {inactiveCredentials?.privateKey}+ </CredentialDisplay>+ </>+ }+ />+ );+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsxindex 7927e39604..9e216aee33 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx@@ -21,6 +21,7 @@ import { OpenRouterApiKeyRotationParametersFields } from "./OpenRouterApiKeyRotaimport { RedisCredentialsRotationParametersFields } from "./RedisCredentialsRotationParametersFields";import { SalesforceOauthCredentialsRotationParametersFields } from "./SalesforceOauthCredentialsRotationParametersFields";import { SqlCredentialsRotationParametersFields } from "./shared";+import { SnowflakeUserKeyPairRotationParametersFields } from "./SnowflakeUserKeyPairRotationParametersFields";import { SupabaseApiKeyRotationParametersFields } from "./SupabaseApiKeyRotationParametersFields";import { UnixLinuxLocalAccountRotationParametersFields } from "./UnixLinuxLocalAccountRotationParametersFields";import { WindowsLocalAccountRotationParametersFields } from "./WindowsLocalAccountRotationParametersFields";@@ -50,7 +51,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.SalesforceOauthCredentials]: SalesforceOauthCredentialsRotationParametersFields,[SecretRotation.DatadogApplicationKeySecret]: DatadogApplicationKeySecretRotationParametersFields,[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationParametersFields,- [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationParametersFields+ [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationParametersFields,+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationParametersFields};export const SecretRotationV2ParametersFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsxnew file mode 100644index 0000000000..8929cc81f8--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx@@ -0,0 +1,69 @@+import { Controller, useFormContext } from "react-hook-form";+import { SingleValue } from "react-select";+import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { FilterableSelect, FormControl, Tooltip } from "@app/components/v2";+import { useSnowflakeConnectionListUsers } from "@app/hooks/api/appConnections/snowflake";+import { TSnowflakeUser } from "@app/hooks/api/appConnections/snowflake/types";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++export const SnowflakeUserKeyPairRotationParametersFields = () => {+ const { control, watch } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.SnowflakeUserKeyPair;+ }+ >();++ const connectionId = watch("connection.id");++ const { data: users, isPending: isUsersPending } = useSnowflakeConnectionListUsers(connectionId, {+ enabled: Boolean(connectionId)+ });++ return (+ <Controller+ name="parameters.username"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="User"+ helperText={+ <Tooltip+ className="max-w-md"+ content={+ <>+ Ensure that your connection's role has the necessary privileges to list users+ and to alter the selected user's RSA public key.+ </>+ }+ >+ <div>+ <span>Don't see the user you're looking for?</span>{" "}+ <FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />+ </div>+ </Tooltip>+ }+ >+ <FilterableSelect+ menuPlacement="top"+ isLoading={isUsersPending && Boolean(connectionId)}+ isDisabled={!connectionId}+ value={users?.find((user) => user.name === value) ?? null}+ onChange={(option) => {+ const selectedUser = option as SingleValue<TSnowflakeUser>;+ onChange(selectedUser?.name ?? null);+ }}+ options={users}+ placeholder="Select a user..."+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.name}+ />+ </FormControl>+ )}+ />+ );+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsxindex f571a4ae75..048b703805 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx@@ -23,6 +23,7 @@ import { OpenRouterApiKeyRotationReviewFields } from "./OpenRouterApiKeyRotationimport { RedisCredentialsRotationReviewFields } from "./RedisCredentialsRotationReviewFields";import { SalesforceOauthCredentialsRotationReviewFields } from "./SalesforceOauthCredentialsRotationReviewFields";import { SqlCredentialsRotationReviewFields } from "./shared";+import { SnowflakeUserKeyPairRotationReviewFields } from "./SnowflakeUserKeyPairRotationReviewFields";import { SupabaseApiKeyRotationReviewFields } from "./SupabaseApiKeyRotationReviewFields";import { UnixLinuxLocalAccountRotationReviewFields } from "./UnixLinuxLocalAccountRotationReviewFields";import { WindowsLocalAccountRotationReviewFields } from "./WindowsLocalAccountRotationReviewFields";@@ -52,7 +53,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.SalesforceOauthCredentials]: SalesforceOauthCredentialsRotationReviewFields,[SecretRotation.DatadogApplicationKeySecret]: DatadogApplicationKeySecretRotationReviewFields,[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationReviewFields,- [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationReviewFields+ [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationReviewFields,+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationReviewFields};export const SecretRotationV2ReviewFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsxnew file mode 100644index 0000000000..2b91e407f8--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsx@@ -0,0 +1,29 @@+import { useFormContext } from "react-hook-form";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { GenericFieldLabel } from "@app/components/v2";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++import { SecretRotationReviewSection } from "./shared";++export const SnowflakeUserKeyPairRotationReviewFields = () => {+ const { watch } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.SnowflakeUserKeyPair;+ }+ >();++ const [{ username }, { privateKey, publicKey }] = watch(["parameters", "secretsMapping"]);++ return (+ <>+ <SecretRotationReviewSection label="Parameters">+ <GenericFieldLabel label="User">{username}</GenericFieldLabel>+ </SecretRotationReviewSection>+ <SecretRotationReviewSection label="Secrets Mapping">+ <GenericFieldLabel label="Private Key">{privateKey}</GenericFieldLabel>+ <GenericFieldLabel label="Public Key">{publicKey}</GenericFieldLabel>+ </SecretRotationReviewSection>+ </>+ );+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsxindex b9dfb92d48..c195131e95 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx@@ -20,6 +20,7 @@ import { OpenRouterApiKeyRotationSecretsMappingFields } from "./OpenRouterApiKeyimport { RedisCredentialsRotationSecretsMappingFields } from "./RedisCredentialsRotationSecretsMappingFields";import { SalesforceOauthCredentialsRotationSecretsMappingFields } from "./SalesforceOauthCredentialsRotationSecretsMappingFields";import { SqlCredentialsRotationSecretsMappingFields } from "./shared";+import { SnowflakeUserKeyPairRotationSecretsMappingFields } from "./SnowflakeUserKeyPairRotationSecretsMappingFields";import { SupabaseApiKeyRotationSecretsMappingFields } from "./SupabaseApiKeyRotationSecretsMappingFields";import { UnixLinuxLocalAccountRotationSecretsMappingFields } from "./UnixLinuxLocalAccountRotationSecretsMappingFields";import { WindowsLocalAccountRotationSecretsMappingFields } from "./WindowsLocalAccountRotationSecretsMappingFields";@@ -51,7 +52,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.DatadogApplicationKeySecret]:DatadogApplicationKeySecretRotationSecretsMappingFields,[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationSecretsMappingFields,- [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationSecretsMappingFields+ [SecretRotation.FireworksApiKey]: FireworksApiKeyRotationSecretsMappingFields,+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationSecretsMappingFields};export const SecretRotationV2SecretsMappingFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SnowflakeUserKeyPairRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SnowflakeUserKeyPairRotationSecretsMappingFields.tsxnew file mode 100644index 0000000000..9f3809f5fd--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SnowflakeUserKeyPairRotationSecretsMappingFields.tsx@@ -0,0 +1,58 @@+import { Controller, useFormContext } from "react-hook-form";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { FormControl, Input } from "@app/components/v2";+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";++import { SecretsMappingTable } from "./shared";++export const SnowflakeUserKeyPairRotationSecretsMappingFields = () => {+ const { control } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.SnowflakeUserKeyPair;+ }+ >();++ const { rotationOption } = useSecretRotationV2Option(SecretRotation.SnowflakeUserKeyPair);++ const items = [+ {+ name: "Private Key",+ input: (+ <Controller+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error)} errorText={error?.message}>+ <Input+ value={value}+ onChange={onChange}+ placeholder={rotationOption?.template.secretsMapping.privateKey}+ />+ </FormControl>+ )}+ control={control}+ name="secretsMapping.privateKey"+ />+ )+ },+ {+ name: "Public Key",+ input: (+ <Controller+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error)} errorText={error?.message}>+ <Input+ value={value}+ onChange={onChange}+ placeholder={rotationOption?.template.secretsMapping.publicKey}+ />+ </FormControl>+ )}+ control={control}+ name="secretsMapping.publicKey"+ />+ )+ }+ ];++ return <SecretsMappingTable items={items} />;+};diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.tsindex 7695ebc66f..6ec25f28a6 100644--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts@@ -27,6 +27,7 @@ import { OpenAIServiceAccountRotationSchema } from "./openai-service-account-rotimport { OracleDBCredentialsRotationSchema } from "./oracledb-credentials-rotation-schema";import { RedisCredentialsRotationSchema } from "./redis-credentials-rotation-schema";import { SalesforceOauthCredentialsRotationSchema } from "./salesforce-oauth-credentials-rotation-schema";+import { SnowflakeUserKeyPairRotationSchema } from "./snowflake-user-key-pair-rotation-schema";import { SupabaseApiKeyRotationSchema } from "./supabase-api-key-rotation-schema";import { UnixLinuxLocalAccountRotationSchema } from "./unix-linux-local-account-rotation-schema";import { WindowsLocalAccountRotationSchema } from "./windows-local-account-rotation-schema";@@ -58,7 +59,8 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>SalesforceOauthCredentialsRotationSchema,DatadogApplicationKeySecretRotationSchema,ConvexAccessKeyRotationSchema,- FireworksApiKeyRotationSchema+ FireworksApiKeyRotationSchema,+ SnowflakeUserKeyPairRotationSchema]),z.object({ id: z.string().optional() }))diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/snowflake-user-key-pair-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/snowflake-user-key-pair-rotation-schema.tsnew file mode 100644index 0000000000..2347ea66a2--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/snowflake-user-key-pair-rotation-schema.ts@@ -0,0 +1,17 @@+import { z } from "zod";++import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++export const SnowflakeUserKeyPairRotationSchema = z+ .object({+ type: z.literal(SecretRotation.SnowflakeUserKeyPair),+ parameters: z.object({+ username: z.string().trim().min(1, "User required")+ }),+ secretsMapping: z.object({+ privateKey: z.string().trim().min(1, "Private Key required"),+ publicKey: z.string().trim().min(1, "Public Key required")+ })+ })+ .merge(BaseSecretRotationSchema);diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.tsindex 839c167a45..098ab2edae 100644--- a/frontend/src/helpers/secretRotationsV2.ts+++ b/frontend/src/helpers/secretRotationsV2.ts@@ -124,6 +124,11 @@ export const SECRET_ROTATION_MAP: Record<name: "Fireworks Secret",image: "Fireworks.png",size: 50+ },+ [SecretRotation.SnowflakeUserKeyPair]: {+ name: "Snowflake User Key Pair",+ image: "Snowflake.png",+ size: 50}};@@ -151,7 +156,8 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.SalesforceOauthCredentials]: AppConnection.Salesforce,[SecretRotation.DatadogApplicationKeySecret]: AppConnection.Datadog,[SecretRotation.ConvexAccessKey]: AppConnection.Convex,- [SecretRotation.FireworksApiKey]: AppConnection.Fireworks+ [SecretRotation.FireworksApiKey]: AppConnection.Fireworks,+ [SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake};// if a rotation can potentially have downtime due to rotating a single credential set this to false@@ -179,7 +185,8 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {[SecretRotation.SalesforceOauthCredentials]: true,[SecretRotation.DatadogApplicationKeySecret]: true,[SecretRotation.ConvexAccessKey]: true,- [SecretRotation.FireworksApiKey]: true+ [SecretRotation.FireworksApiKey]: true,+ [SecretRotation.SnowflakeUserKeyPair]: true};export const getRotateAtLocal = ({ hours, minutes }: TSecretRotationV2["rotateAtUtc"]) => {diff --git a/frontend/src/hooks/api/appConnections/snowflake/queries.tsx b/frontend/src/hooks/api/appConnections/snowflake/queries.tsxindex 80532ca328..6400a51472 100644--- a/frontend/src/hooks/api/appConnections/snowflake/queries.tsx+++ b/frontend/src/hooks/api/appConnections/snowflake/queries.tsx@@ -3,14 +3,21 @@ import { useQuery, UseQueryOptions } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";import { appConnectionKeys } from "@app/hooks/api/appConnections";-import { TListSnowflakeSchemas, TSnowflakeDatabase, TSnowflakeSchema } from "./types";+import {+ TListSnowflakeSchemas,+ TSnowflakeDatabase,+ TSnowflakeSchema,+ TSnowflakeUser+} from "./types";const snowflakeConnectionKeys = {all: [...appConnectionKeys.all, "snowflake"] as const,listDatabases: (connectionId: string) =>[...snowflakeConnectionKeys.all, "databases", connectionId] as const,listSchemas: ({ connectionId, database }: TListSnowflakeSchemas) =>- [...snowflakeConnectionKeys.all, "schemas", connectionId, database] as const+ [...snowflakeConnectionKeys.all, "schemas", connectionId, database] as const,+ listUsers: (connectionId: string) =>+ [...snowflakeConnectionKeys.all, "users", connectionId] as const};export const useSnowflakeConnectionListDatabases = (@@ -63,3 +70,28 @@ export const useSnowflakeConnectionListSchemas = (...options});};++export const useSnowflakeConnectionListUsers = (+ connectionId: string,+ options?: Omit<+ UseQueryOptions<+ TSnowflakeUser[],+ unknown,+ TSnowflakeUser[],+ ReturnType<typeof snowflakeConnectionKeys.listUsers>+ >,+ "queryKey" | "queryFn"+ >+) => {+ return useQuery({+ queryKey: snowflakeConnectionKeys.listUsers(connectionId),+ queryFn: async () => {+ const { data } = await apiRequest.get<{ users: TSnowflakeUser[] }>(+ `/api/v1/app-connections/snowflake/${connectionId}/users`+ );++ return data.users;+ },+ ...options+ });+};diff --git a/frontend/src/hooks/api/appConnections/snowflake/types.ts b/frontend/src/hooks/api/appConnections/snowflake/types.tsindex e71fa955c3..9ff09d1693 100644--- a/frontend/src/hooks/api/appConnections/snowflake/types.ts+++ b/frontend/src/hooks/api/appConnections/snowflake/types.ts@@ -6,6 +6,10 @@ export type TSnowflakeSchema = {name: string;};+export type TSnowflakeUser = {+ name: string;+};+export type TListSnowflakeSchemas = {connectionId: string;database: string;diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.tsindex 86de187c58..e338afaa47 100644--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts@@ -22,7 +22,8 @@ export enum SecretRotation {SalesforceOauthCredentials = "salesforce-oauth-credentials",DatadogApplicationKeySecret = "datadog-application-key-secret",ConvexAccessKey = "convex-access-key",- FireworksApiKey = "fireworks-api-key"+ FireworksApiKey = "fireworks-api-key",+ SnowflakeUserKeyPair = "snowflake-user-key-pair"}export enum SecretRotationStatus {diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.tsindex cb12686b90..734e29c4a9 100644--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts@@ -104,6 +104,11 @@ import {TSalesforceOauthCredentialsRotationGeneratedCredentialsResponse,TSalesforceOauthCredentialsRotationOption} from "./salesforce-oauth-credentials-rotation";+import {+ TSnowflakeUserKeyPairRotation,+ TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse,+ TSnowflakeUserKeyPairRotationOption+} from "./snowflake-user-key-pair-rotation";import {TSupabaseApiKeyRotation,TSupabaseApiKeyRotationGeneratedCredentialsResponse,@@ -145,6 +150,7 @@ export type TSecretRotationV2 = (| TDatadogApplicationKeySecretRotation| TConvexAccessKeyRotation| TFireworksApiKeyRotation+ | TSnowflakeUserKeyPairRotation) & {secrets: (SecretV3RawSanitized | null)[];};@@ -170,7 +176,8 @@ export type TSecretRotationV2Option =| TSalesforceOauthCredentialsRotationOption| TDatadogApplicationKeySecretRotationOption| TConvexAccessKeyRotationOption- | TFireworksApiKeyRotationOption;+ | TFireworksApiKeyRotationOption+ | TSnowflakeUserKeyPairRotationOption;export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };@@ -200,7 +207,8 @@ export type TViewSecretRotationGeneratedCredentialsResponse =| TSalesforceOauthCredentialsRotationGeneratedCredentialsResponse| TDatadogApplicationKeySecretRotationGeneratedCredentialsResponse| TConvexAccessKeyRotationGeneratedCredentialsResponse- | TFireworksApiKeyRotationGeneratedCredentialsResponse;+ | TFireworksApiKeyRotationGeneratedCredentialsResponse+ | TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse;export type TCreateSecretRotationV2DTO = DiscriminativePick<TSecretRotationV2,@@ -279,6 +287,7 @@ export type TSecretRotationOptionMap = {[SecretRotation.DatadogApplicationKeySecret]: TDatadogApplicationKeySecretRotationOption;[SecretRotation.ConvexAccessKey]: TConvexAccessKeyRotationOption;[SecretRotation.FireworksApiKey]: TFireworksApiKeyRotationOption;+ [SecretRotation.SnowflakeUserKeyPair]: TSnowflakeUserKeyPairRotationOption;};export type TSecretRotationGeneratedCredentialsResponseMap = {@@ -306,6 +315,7 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {[SecretRotation.DatadogApplicationKeySecret]: TDatadogApplicationKeySecretRotationGeneratedCredentialsResponse;[SecretRotation.ConvexAccessKey]: TConvexAccessKeyRotationGeneratedCredentialsResponse;[SecretRotation.FireworksApiKey]: TFireworksApiKeyRotationGeneratedCredentialsResponse;+ [SecretRotation.SnowflakeUserKeyPair]: TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse;};// Unified type for local account reconciliation (Unix/Linux, Windows, and HP iLO)diff --git a/frontend/src/hooks/api/secretRotationsV2/types/snowflake-user-key-pair-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/snowflake-user-key-pair-rotation.tsnew file mode 100644index 0000000000..4013cc1789--- /dev/null+++ b/frontend/src/hooks/api/secretRotationsV2/types/snowflake-user-key-pair-rotation.ts@@ -0,0 +1,37 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";+import {+ TSecretRotationV2Base,+ TSecretRotationV2GeneratedCredentialsResponseBase+} from "@app/hooks/api/secretRotationsV2/types/shared";++export type TSnowflakeUserKeyPairRotation = TSecretRotationV2Base & {+ type: SecretRotation.SnowflakeUserKeyPair;+ parameters: {+ username: string;+ };+ secretsMapping: {+ privateKey: string;+ publicKey: string;+ };+};++export type TSnowflakeUserKeyPairRotationGeneratedCredentials = {+ privateKey: string;+ publicKey: string;+};++export type TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse =+ TSecretRotationV2GeneratedCredentialsResponseBase<+ SecretRotation.SnowflakeUserKeyPair,+ TSnowflakeUserKeyPairRotationGeneratedCredentials+ >;++export type TSnowflakeUserKeyPairRotationOption = {+ name: string;+ type: SecretRotation.SnowflakeUserKeyPair;+ connection: AppConnection.Snowflake;+ template: {+ secretsMapping: TSnowflakeUserKeyPairRotation["secretsMapping"];+ };+};