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
enhance docs to explain which roles are required to connect into infisical
adilson7eb3e3ac6d28
diff --git a/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts b/backend/src/services/app-connection/snowflake/snowflake-connection-fns.tsindex 134b8cea00..0f6c3a9ef1 100644--- a/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts+++ b/backend/src/services/app-connection/snowflake/snowflake-connection-fns.ts@@ -12,6 +12,20 @@ const noop = () => {};const SNOWFLAKE_EXCLUDED_DATABASES = new Set(["SNOWFLAKE", "SNOWFLAKE_SAMPLE_DATA"]);const SNOWFLAKE_EXCLUDED_SCHEMAS = new Set(["INFORMATION_SCHEMA"]);+const withTimeout = async <T>(promise: Promise<T>, ms: number, onTimeout: () => Error): Promise<T> => {+ let timeoutHandle: NodeJS.Timeout | undefined;+ try {+ return await Promise.race([+ promise,+ new Promise<T>((_, reject) => {+ timeoutHandle = setTimeout(() => reject(onTimeout()), ms);+ })+ ]);+ } finally {+ if (timeoutHandle) clearTimeout(timeoutHandle);+ }+};+export const quoteSnowflakeIdent = (name: string) => `"${name.replace(/"/g, '""')}"`;export const getSnowflakeConnectionListItem = () => {@@ -30,23 +44,14 @@ export const getSnowflakeClient = async (credentials: TSnowflakeConnection["credapplication: "Infisical"});- await new Promise<void>((resolve, reject) => {- client.connectAsync((err) => (err ? reject(err) : resolve())).catch(reject);- });-try {- let timeoutHandle: NodeJS.Timeout | undefined;- const isValid = await Promise.race<boolean>([+ await client.connectAsync();++ const isValid = await withTimeout(client.isValidAsync(),- new Promise<boolean>((_, reject) => {- timeoutHandle = setTimeout(- () => reject(new BadRequestError({ message: "Snowflake connection validation timed out" })),- 10000- );- })- ]).finally(() => {- if (timeoutHandle) clearTimeout(timeoutHandle);- });+ 10_000,+ () => new BadRequestError({ message: "Snowflake connection validation timed out" })+ );if (!isValid) {throw new BadRequestError({diff --git a/docs/integrations/app-connections/snowflake.mdx b/docs/integrations/app-connections/snowflake.mdxindex a0a4fe2bec..e95267addc 100644--- a/docs/integrations/app-connections/snowflake.mdx+++ b/docs/integrations/app-connections/snowflake.mdx@@ -8,7 +8,7 @@ Infisical supports connecting to Snowflake using a **Username** and a **Programm## Prerequisites- A [Snowflake account](https://app.snowflake.com/) with permission to create Programmatic Access Tokens.-- The **account identifier** for your Snowflake instance (e.g. `xy12345.us-east-1`). You can find it in the Snowflake URL you sign in to (`https://<account-identifier>.snowflakecomputing.com`) or under **Admin → Accounts** in Snowsight.+- The **account identifier** for your Snowflake instance, which combines your organization name and account name. You can find it in your Snowflake login URL (`https://app.snowflake.com/orgName/accountName/#/account/users`) or under **Account Details** in Snowsight.## Create a Snowflake Programmatic Access Token@@ -28,31 +28,45 @@ Infisical supports connecting to Snowflake using a **Username** and a **Programm<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. The snippet below grants the minimum required privileges (alternatively, assign the **ACCOUNTADMIN** role).+ ++ If you decide to go with a custom role, you just need to run the following snippet:+```SQL-- Grant INFISICAL user access to SECRET_SYNC_TESTCREATE ROLE IF NOT EXISTS INFISICAL_ROLE;- GRANT ROLE INFISICAL_ROLE TO USER INFISICAL;+ GRANT ROLE INFISICAL_ROLE TO USER INFISICAL; -- Change INFISICAL to be your userGRANT 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 ALL PRIVILEGES ON ALL SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE;- GRANT ALL PRIVILEGES ON FUTURE SECRETS IN 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;+ GRANT OWNERSHIP ON FUTURE SECRETS IN SCHEMA SECRET_SYNC_TEST.PUBLIC TO ROLE INFISICAL_ROLE REVOKE CURRENT GRANTS;```- + <Note>+ **Transfers ownership—you cannot rely on grants alone.** Grants on the database and schema cover access, but **each existing secret in the sync target schema stays owned by whoever created it** unless you intentionally move ownership. Infisical’s Snowflake user must run with a role that **owns every secret Infisical will manage** (`GRANT OWNERSHIP ON ALL SECRETS IN SCHEMA ...` plus `OWNERSHIP ON FUTURE SECRETS IN SCHEMA ...` as shown above). If anything in that schema is still owned elsewhere, syncing can fail when Infisical runs `CREATE OR REPLACE SECRET` or `DROP SECRET`.+ </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.++ + ++```SQLCREATE NETWORK POLICY INFISICAL_SYNC_POLICYALLOWED_IP_LIST = ('0.0.0.0/0')COMMENT = 'Allow access from any IP';++ ALTER USER INFISICAL set NETWORK_POLICY = 'INFISICAL_SYNC_POLICY';```- - + <Note>+ 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).+ </Note></Step><Step title="Generate a Programmatic Access Token">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.@@ -89,8 +103,8 @@ Infisical supports connecting to Snowflake using a **Username** and a **ProgrammComplete the form with:- A **name** for the connection (e.g. `snowflake-prod`)- An optional **description**- - The Snowflake **Account** identifier (e.g. `xy12345.us-east-1`)- - The Snowflake **Username** (login name)+ - The Snowflake **Account** identifier (e.g. `orgName-accountName`)+ - The Snowflake **Username** (The name of the user that was created)- The **Programmatic Access Token** generated in the previous section