Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

apply review recommendations

adilson0e09ee696c1f
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.ts
index 313451ef02..2cccea55b9 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
@@ -94,6 +94,10 @@ export const snowflakeUserKeyPairRotationFactory: TRotationFactory<
}
};
+ // Snowflake's DESC USER can return the literal string "null" when a key slot is unset.
+ const isPresentFingerprint = (value: string | null | undefined): value is string =>
+ typeof value === "string" && value.trim() !== "" && value.trim().toLowerCase() !== "null";
+
const readFingerprints = async (client: snowflake.Connection, resolvedUsername: string) => {
// 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.
@@ -106,7 +110,7 @@ export const snowflakeUserKeyPairRotationFactory: TRotationFactory<
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 (isPresentFingerprint(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;
}
diff --git a/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx b/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx
index 878b0ff30d..a0f17877eb 100644
--- a/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx
+++ b/docs/documentation/platform/secret-rotation/snowflake-user-key-pair.mdx
@@ -15,29 +15,7 @@ Infisical's Snowflake User Key Pair rotation generates a **2048-bit RSA key pair
1. Create a [Snowflake Connection](/integrations/app-connections/snowflake) with the required **Secret Rotation** permissions.
- The connection's role must be able to alter the target user. Grant a role that can manage the user and assign it to your connection user:
-
- ```SQL
- -- create a role Infisical will use to manage the target user
- CREATE ROLE IF NOT EXISTS INFISICAL_ROTATION_ROLE;
-
- -- allow the role to alter the target user's RSA public key
- GRANT OWNERSHIP ON USER MY_TARGET_USER TO ROLE INFISICAL_ROTATION_ROLE;
-
- -- (optional) allow the role to create the target user if it does not exist yet
- GRANT CREATE USER ON ACCOUNT TO ROLE INFISICAL_ROTATION_ROLE;
-
- -- assign the role to the user backing your Snowflake Connection
- GRANT ROLE INFISICAL_ROTATION_ROLE TO USER MY_CONNECTION_USER;
- ```
-
- <Tip>
- To learn more about managing users and privileges in Snowflake, see their [access control documentation](https://docs.snowflake.com/en/user-guide/security-access-control-overview).
- </Tip>
-
-2. Decide on the target user whose key pair you want to rotate.
-
- If the user already exists, the connection's role only needs privileges to **alter** it (e.g. `OWNERSHIP` on the user). If the user does **not** exist, Infisical creates it as a key-pair-only `SERVICE` user, which additionally requires the `CREATE USER` privilege on the account.
+2. Decide on the target user whose key pair you want to rotate. New users are created as key-pair-only `SERVICE` users.
<Note>
Users created by Infisical are not deleted when their credentials are revoked.
diff --git a/docs/integrations/app-connections/snowflake.mdx b/docs/integrations/app-connections/snowflake.mdx
index 58cfffd0e3..c23bb6affa 100644
--- a/docs/integrations/app-connections/snowflake.mdx
+++ b/docs/integrations/app-connections/snowflake.mdx
@@ -29,31 +29,6 @@ Infisical supports connecting to Snowflake using a **Username** and a **Programm
![Generate Programmatic Access Token](/images/app-connections/snowflake/step-2.png)
</Step>
- <Step title="Configure user details and role">
- Provide a **Username** and assign a role. The role must have permission to create and manage secrets in the target database.
-
- ![Configure User](/images/app-connections/snowflake/step-3.png)
-
- If you decide to go with a custom role, you just need to run the following snippet, which grants the minimum privileges required for operations on specific tables and schemas. To do this, select the **Projects** tab and click on **Workspaces** to open the query editor.
-
- ![Go into workspace](/images/app-connections/snowflake/step-4-workspace.png)
-
- ```SQL
- -- Grant INFISICAL user access to SECRET_SYNC_TEST
- CREATE ROLE IF NOT EXISTS INFISICAL_ROLE;
- GRANT ROLE INFISICAL_ROLE TO USER INFISICAL; -- Change INFISICAL to be your user
-
- GRANT ALL PRIVILEGES ON DATABASE SECRET_SYNC_TEST TO ROLE INFISICAL_ROLE;
- GRANT ALL PRIVILEGES ON SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE;
- GRANT OWNERSHIP ON ALL SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE REVOKE CURRENT GRANTS; -- Transfers ownership
- GRANT OWNERSHIP ON FUTURE SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE REVOKE CURRENT GRANTS; -- Transfers ownership
- ```
-
- <Note>
- If you select a custom role, note that **secret ownership is enforced per object**. Existing secrets in the target schema remain owned by their creator unless you transfer ownership. Infisical must use a role that **owns every secret it manages** (required for `CREATE OR REPLACE SECRET` and `DROP SECRET`). If the schema already has secrets, run the `GRANT OWNERSHIP ON ALL SECRETS ...` statement; always keep the `GRANT OWNERSHIP ON FUTURE SECRETS ...` statement.
- </Note>
- </Step>
-
<Step title="Create a network policy">
Programmatic Access Tokens require an attached network policy that defines the IPs allowed to authenticate as this user. To create one, hover over **Projects**, click on **Workspaces**, and create a network policy. The snippet below creates one that allows access from any IP.
@@ -73,6 +48,62 @@ Infisical supports connecting to Snowflake using a **Username** and a **Programm
Be careful with the IPs you allow in your network policy. Using `0.0.0.0/0` allows access from **any IP address**, which can be dangerous in production. Prefer restricting the list to only the IP ranges that should be allowed to authenticate (for example, your corporate NAT(s) and/or Infisical's outbound IPs if you have them).
</Warning>
</Step>
+
+ <Step title="Configure user details and role">
+ Provide a **Username** and assign a role. Then grant the role the privileges required for how you intend to use the connection.
+
+ ![Configure User](/images/app-connections/snowflake/step-3.png)
+
+ To run the grant statements below, select the **Projects** tab and click on **Workspaces** to open the query editor.
+
+ ![Go into workspace](/images/app-connections/snowflake/step-4-workspace.png)
+
+ <Tabs>
+ <Tab title="Secret Syncs">
+ The role must have permission to create and manage secrets in the target database. The following snippet grants the minimum privileges required for operations on specific tables and schemas.
+
+ ```SQL
+ -- Grant INFISICAL user access to SECRET_SYNC_TEST
+ CREATE ROLE IF NOT EXISTS INFISICAL_ROLE;
+ GRANT ROLE INFISICAL_ROLE TO USER INFISICAL; -- Change INFISICAL to be your user
+
+ GRANT ALL PRIVILEGES ON DATABASE SECRET_SYNC_TEST TO ROLE INFISICAL_ROLE;
+ GRANT ALL PRIVILEGES ON SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE;
+ GRANT OWNERSHIP ON ALL SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE REVOKE CURRENT GRANTS; -- Transfers ownership
+ GRANT OWNERSHIP ON FUTURE SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE REVOKE CURRENT GRANTS; -- Transfers ownership
+ ```
+
+ <Note>
+ If you select a custom role, note that **secret ownership is enforced per object**. Existing secrets in the target schema remain owned by their creator unless you transfer ownership. Infisical must use a role that **owns every secret it manages** (required for `CREATE OR REPLACE SECRET` and `DROP SECRET`). If the schema already has secrets, run the `GRANT OWNERSHIP ON ALL SECRETS ...` statement; always keep the `GRANT OWNERSHIP ON FUTURE SECRETS ...` statement.
+ </Note>
+ </Tab>
+ <Tab title="Secret Rotations">
+ For [Snowflake User Key Pair rotation](/documentation/platform/secret-rotation/snowflake-user-key-pair), the connection's role must be able to alter the target user whose key pair will be rotated. Grant a role that can manage the user and assign it to your connection user:
+
+ ```SQL
+ -- create a role Infisical will use to manage the target user
+ CREATE ROLE IF NOT EXISTS INFISICAL_ROTATION_ROLE;
+
+ -- allow the role to alter the target user's RSA public key
+ GRANT OWNERSHIP ON USER MY_TARGET_USER TO ROLE INFISICAL_ROTATION_ROLE;
+
+ -- (optional) allow the role to create the target user if it does not exist yet
+ GRANT CREATE USER ON ACCOUNT TO ROLE INFISICAL_ROTATION_ROLE;
+
+ -- assign the role to the user backing your Snowflake Connection
+ GRANT ROLE INFISICAL_ROTATION_ROLE TO USER MY_CONNECTION_USER;
+ ```
+
+ If the target user already exists, the connection's role only needs privileges to **alter** it (e.g. `OWNERSHIP` on the user). If the user does **not** exist yet, the role additionally requires the `CREATE USER` privilege on the account.
+
+ <Tip>
+ To learn more about managing users and privileges in Snowflake, see their [access control documentation](https://docs.snowflake.com/en/user-guide/security-access-control-overview).
+ </Tip>
+ </Tab>
+ </Tabs>
+ </Step>
+
+
<Step title="Generate a Programmatic Access Token">
Hover over **Governance & Security** and click on **Users & roles**. Select the user you want to use in Infisical. Open the **Programmatic access tokens** tab and click **Generate new token**. Give the token a descriptive name (e.g. `infisical`) and configure its expiration and role restrictions according to your security policy.
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx
index ffd15661a0..5c95d371f6 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SnowflakeUserKeyPairRotationParametersFields.tsx
@@ -64,9 +64,10 @@ export const SnowflakeUserKeyPairRotationParametersFields = () => {
getNewOptionData={(inputValue) => ({ name: inputValue })}
isValidNewOption={(inputValue) => inputValue.trim().length > 0}
options={users}
- placeholder="Select or enter a user..."
+ placeholder="Add user..."
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.name}
+ isClearable
/>
</FormControl>
)}