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
add rsa bit size as an option
adilson4045378e9dc4
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.tsindex 2cccea55b9..d0ce03e137 100644--- 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.ts@@ -23,8 +23,6 @@ import {TSnowflakeUserKeyPairRotationWithConnection} from "./snowflake-user-key-pair-rotation-types";-const RSA_MODULUS_LENGTH = 2048;-const RSA_PUBLIC_KEY_FIRST_SLOT = "RSA_PUBLIC_KEY";const RSA_PUBLIC_KEY_SECOND_SLOT = "RSA_PUBLIC_KEY_2";@@ -35,12 +33,12 @@ type TSnowflakePublicKeySlot = (typeof RSA_PUBLIC_KEY_SLOTS)[number];const slotForIndex = (index: number): TSnowflakePublicKeySlot =>index === 0 ? RSA_PUBLIC_KEY_FIRST_SLOT : RSA_PUBLIC_KEY_SECOND_SLOT;-const generateRsaKeyPair = () =>+const generateRsaKeyPair = (modulusLength: number) =>new Promise<{ privateKey: string; publicKey: string }>((resolve, reject) => {crypto.nativeCrypto.generateKeyPair("rsa",{- modulusLength: RSA_MODULUS_LENGTH,+ modulusLength,publicKeyEncoding: { type: "spki", format: "pem" },privateKeyEncoding: { type: "pkcs8", format: "pem" }},@@ -71,7 +69,7 @@ export const snowflakeUserKeyPairRotationFactory: TRotationFactory<> = (secretRotation) => {const {connection,- parameters: { username },+ parameters: { username, modulusLength },activeIndex,secretsMapping} = secretRotation;@@ -176,7 +174,7 @@ export const snowflakeUserKeyPairRotationFactory: TRotationFactory<callback) => {// On creation the first credential always occupies slot 0 (activeIndex defaults to 0).- const keyPair = await generateRsaKeyPair();+ const keyPair = await generateRsaKeyPair(modulusLength);await ensureUserExists();// Block creation if the RSA_PUBLIC_KEY slot already holds a key, so we never overwrite a@@ -204,7 +202,7 @@ export const snowflakeUserKeyPairRotationFactory: TRotationFactory<// (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();+ const keyPair = await generateRsaKeyPair(modulusLength);await setPublicKeyForSlot(slotForIndex(inactiveIndex), keyPair);return callback(keyPair);};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.tsindex 449d216e0f..5d70430438 100644--- 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.ts@@ -24,7 +24,11 @@ const SnowflakeUserKeyPairRotationParametersSchema = z.object({.string().trim().min(1, "User Required")- .describe(SecretRotations.PARAMETERS.SNOWFLAKE_USER_KEY_PAIR.username)+ .describe(SecretRotations.PARAMETERS.SNOWFLAKE_USER_KEY_PAIR.username),+ modulusLength: z+ .union([z.literal(2048), z.literal(4096)])+ .default(2048)+ .describe(SecretRotations.PARAMETERS.SNOWFLAKE_USER_KEY_PAIR.modulusLength)});const SnowflakeUserKeyPairRotationSecretsMappingSchema = z.object({diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 33d30e1f7e..5c789d14bc 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3567,7 +3567,8 @@ export const SecretRotations = {},SNOWFLAKE_USER_KEY_PAIR: {username:- "The Snowflake user whose RSA key pair will be rotated. If the user does not exist, it is created as a key-pair-only SERVICE user."+ "The Snowflake user whose RSA key pair will be rotated. If the user does not exist, it is created as a key-pair-only SERVICE user.",+ modulusLength: "The modulus length in bits of the generated RSA key pairs. Defaults to 2048."}},SECRETS_MAPPING: {diff --git a/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx b/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdxindex a0f17877eb..f1d736d911 100644--- a/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx+++ b/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx@@ -9,7 +9,7 @@ description: "Learn how to automatically rotate a Snowflake user's RSA key pair.This rotation maintains two active credential sets with overlapping validity, ensuring zero-downtime during rotation cycles. It uses Snowflake's two public-key slots (`RSA_PUBLIC_KEY` and `RSA_PUBLIC_KEY_2`), alternating between them on each rotation so the retired key pair stays valid until the next cycle.</Note>-Infisical's Snowflake User Key Pair rotation generates a **2048-bit RSA key pair** and assigns its public key to a target Snowflake user for [key-pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth). On each rotation, Infisical generates a fresh key pair, writes the public key to the currently-inactive slot on the user, and maps the new private and public keys to the secrets of your choice.+Infisical's Snowflake User Key Pair rotation generates an **RSA key pair** (2048-bit or 4096-bit, defaulting to 2048) and assigns its public key to a target Snowflake user for [key-pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth). On each rotation, Infisical generates a fresh key pair, writes the public key to the currently-inactive slot on the user, and maps the new private and public keys to the secrets of your choice.## Prerequisites@@ -51,10 +51,11 @@ Infisical's Snowflake User Key Pair rotation generates a **2048-bit RSA key pair- **Rotate At** - the local time of day when rotation should occur once the interval has elapsed.- **Auto-Rotation Enabled** - whether secrets should automatically be rotated once the rotation interval has elapsed. Disable this option to manually rotate secrets or pause secret rotation.- 4. Select the Snowflake user whose key pair should be rotated, or enter a new username to create one. Then click **Next**.+ 4. Select the Snowflake user whose key pair should be rotated (or enter a new username to create one) and choose the **RSA Modulus Length**. Then click **Next**.- **User** - the Snowflake user whose RSA key pair will be rotated. Select an existing user, or type a new username to create one. New users are created as key-pair-only `SERVICE` users.+ - **RSA Modulus Length** - the size in bits of the generated RSA key pairs (2048 or 4096). Defaults to 2048. Changing this on an existing rotation only affects keys generated on future rotations.5. Specify the secret names that the generated key pair should be mapped to. Then click **Next**.@@ -98,7 +99,8 @@ Infisical's Snowflake User Key Pair rotation generates a **2048-bit RSA key pair"minutes": 0},"parameters": {- "username": "MY_SERVICE_USER"+ "username": "MY_SERVICE_USER",+ "modulusLength": 2048},"secretsMapping": {"privateKey": "SNOWFLAKE_PRIVATE_KEY",@@ -153,7 +155,8 @@ Infisical's Snowflake User Key Pair rotation generates a **2048-bit RSA key pair"lastRotationMessage": null,"type": "snowflake-user-key-pair","parameters": {- "username": "MY_SERVICE_USER"+ "username": "MY_SERVICE_USER",+ "modulusLength": 2048}}}diff --git a/docs/images/secret-rotations-v2/snowflake-user-key-pair/step-3.png b/docs/images/secret-rotations-v2/snowflake-user-key-pair/step-3.pngindex 7984e41fa2..59ebf06524 100644Binary files a/docs/images/secret-rotations-v2/snowflake-user-key-pair/step-3.png and b/docs/images/secret-rotations-v2/snowflake-user-key-pair/step-3.png differdiff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsxindex 1549939aa5..63a8efbef4 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx@@ -4,7 +4,7 @@ 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 { FormControl, Tooltip } from "@app/components/v2";+import { FormControl, Select, SelectItem, Tooltip } from "@app/components/v2";import { CreatableSelect } from "@app/components/v2/CreatableSelect";import { useSnowflakeConnectionListUsers } from "@app/hooks/api/appConnections/snowflake";import { TSnowflakeUser } from "@app/hooks/api/appConnections/snowflake/types";@@ -13,6 +13,8 @@ import { SecretRotation } from "@app/hooks/api/secretRotationsV2";// The create-option row shows its own label ("Add user ...") while the form value stays the raw username.type TUserOption = TSnowflakeUser & { label?: string };+const RSA_MODULUS_LENGTHS = [2048, 4096] as const;+export const SnowflakeUserKeyPairRotationParametersFields = () => {const { control, watch } = useFormContext<TSecretRotationV2Form & {@@ -28,61 +30,91 @@ export const SnowflakeUserKeyPairRotationParametersFields = () => {});return (- <Controller- name="parameters.username"- control={control}- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- isError={Boolean(error)}- errorText={error?.message}- label="User"- helperText={- isUpdate ? (- "Cannot be updated."- ) : (- <Tooltip- className="max-w-md"- content={- <>- Select an existing Snowflake user, or type a new username to create it. New- users are created as key-pair-only SERVICE users. Ensure your connection's- role has the privileges to list users, alter the user's RSA public key, and- (for new users) create users. If the keys are rotated the user will continue to- exist.- </>- }- >- <div>- <span>Don't see the user you're looking for?</span>{" "}- <FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />- </div>- </Tooltip>- )- }- >- <CreatableSelect<TUserOption>- menuPlacement="top"- isLoading={isUsersPending && Boolean(connectionId) && !isUpdate}- isDisabled={!connectionId || isUpdate}- value={users?.find((user) => user.name === value) ?? (value ? { name: value } : null)}- onChange={(option) => {- const selectedUser = option as SingleValue<TUserOption>;- onChange(selectedUser?.name ?? null);- }}- onCreateOption={(inputValue) => onChange(inputValue)}- getNewOptionData={(inputValue) => ({- name: inputValue,- label: `Add user "${inputValue}"`- })}- isValidNewOption={(inputValue) => inputValue.trim().length > 0}- options={users}- placeholder="Select or add a new user..."- getOptionLabel={(option) => option.label ?? option.name}- getOptionValue={(option) => option.name}- isClearable- />- </FormControl>- )}- />+ <>+ <Controller+ name="parameters.username"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="User"+ helperText={+ isUpdate ? (+ "Cannot be updated."+ ) : (+ <Tooltip+ className="max-w-md"+ content={+ <>+ Select an existing Snowflake user, or type a new username to create it. New+ users are created as key-pair-only SERVICE users. Ensure your connection's+ role has the privileges to list users, alter the user's RSA public key,+ and (for new users) create users. If the keys are rotated the user will+ continue to exist.+ </>+ }+ >+ <div>+ <span>Don't see the user you're looking for?</span>{" "}+ <FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />+ </div>+ </Tooltip>+ )+ }+ >+ <CreatableSelect<TUserOption>+ menuPlacement="top"+ isLoading={isUsersPending && Boolean(connectionId) && !isUpdate}+ isDisabled={!connectionId || isUpdate}+ value={users?.find((user) => user.name === value) ?? (value ? { name: value } : null)}+ onChange={(option) => {+ const selectedUser = option as SingleValue<TUserOption>;+ onChange(selectedUser?.name ?? null);+ }}+ onCreateOption={(inputValue) => onChange(inputValue)}+ getNewOptionData={(inputValue) => ({+ name: inputValue,+ label: `Add user "${inputValue}"`+ })}+ isValidNewOption={(inputValue) => inputValue.trim().length > 0}+ options={users}+ placeholder="Select or add a new user..."+ getOptionLabel={(option) => option.label ?? option.name}+ getOptionValue={(option) => option.name}+ isClearable+ />+ </FormControl>+ )}+ />+ <Controller+ name="parameters.modulusLength"+ control={control}+ defaultValue={2048}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="RSA Modulus Length"+ tooltipText="The size in bits of the generated RSA key pairs. 2048-bit keys are faster to generate and use; 4096-bit keys provide a larger security margin."+ tooltipClassName="max-w-sm"+ >+ <Select+ value={String(value)}+ onValueChange={(val) => onChange(Number(val))}+ className="w-full border border-mineshaft-500"+ position="popper"+ dropdownContainerClassName="max-w-none"+ >+ {RSA_MODULUS_LENGTHS.map((length) => (+ <SelectItem value={String(length)} key={length}>+ {length}-bit+ </SelectItem>+ ))}+ </Select>+ </FormControl>+ )}+ />+ </>);};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsxindex 2b91e407f8..ce29504b37 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SnowflakeUserKeyPairRotationReviewFields.tsx@@ -13,12 +13,16 @@ export const SnowflakeUserKeyPairRotationReviewFields = () => {}>();- const [{ username }, { privateKey, publicKey }] = watch(["parameters", "secretsMapping"]);+ const [{ username, modulusLength }, { privateKey, publicKey }] = watch([+ "parameters",+ "secretsMapping"+ ]);return (<><SecretRotationReviewSection label="Parameters"><GenericFieldLabel label="User">{username}</GenericFieldLabel>+ <GenericFieldLabel label="RSA Modulus Length">{`${modulusLength}-bit`}</GenericFieldLabel></SecretRotationReviewSection><SecretRotationReviewSection label="Secrets Mapping"><GenericFieldLabel label="Private Key">{privateKey}</GenericFieldLabel>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.tsindex 2347ea66a2..84db160f5e 100644--- 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.ts@@ -7,7 +7,8 @@ export const SnowflakeUserKeyPairRotationSchema = z.object({type: z.literal(SecretRotation.SnowflakeUserKeyPair),parameters: z.object({- username: z.string().trim().min(1, "User required")+ username: z.string().trim().min(1, "User required"),+ modulusLength: z.union([z.literal(2048), z.literal(4096)])}),secretsMapping: z.object({privateKey: z.string().trim().min(1, "Private Key required"),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.tsindex 4013cc1789..04add8c721 100644--- 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.ts@@ -9,6 +9,7 @@ export type TSnowflakeUserKeyPairRotation = TSecretRotationV2Base & {type: SecretRotation.SnowflakeUserKeyPair;parameters: {username: string;+ modulusLength: number;};secretsMapping: {privateKey: string;