diff --git a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-fns.ts b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-fns.ts index c26d652cb9..649ab38121 100644 --- a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-fns.ts +++ b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-fns.ts @@ -52,7 +52,7 @@ export const HCVaultSyncFns = { const variables = await listHCVaultVariables({ instanceUrl, accessToken, mount, path }); let tainted = false; - for await (const entry of Object.entries(secretMap)) { + for (const entry of Object.entries(secretMap)) { const [key, { value }] = entry; if (value !== variables[key]) { variables[key] = value; diff --git a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts index c61c384a0a..d0f2a9f654 100644 --- a/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts +++ b/backend/src/services/secret-sync/hc-vault/hc-vault-sync-schemas.ts @@ -1,3 +1,4 @@ +import RE2 from "re2"; import { z } from "zod"; import { SecretSyncs } from "@app/lib/api-docs"; @@ -20,8 +21,8 @@ const HCVaultSyncDestinationConfigSchema = z.object({ .string() .trim() .min(1, "Path required") - .transform((val) => val.trim().replace(/^\/+|\/+$/g, "")) // removes leading/trailing slashes - .refine((val) => /^([a-zA-Z0-9._-]+\/)*[a-zA-Z0-9._-]+$/.test(val), { + .transform((val) => val.replace(/^\/+|\/+$/g, "")) // removes leading/trailing slashes + .refine((val) => new RE2("^([a-zA-Z0-9._-]+/)*[a-zA-Z0-9._-]+$").test(val), { message: "Invalid Vault path format. Use alphanumerics, dots, dashes, underscores, and single slashes between segments." }) diff --git a/docs/integrations/app-connections/hashicorp-vault.mdx b/docs/integrations/app-connections/hashicorp-vault.mdx index c468876d80..de38f24f90 100644 --- a/docs/integrations/app-connections/hashicorp-vault.mdx +++ b/docs/integrations/app-connections/hashicorp-vault.mdx @@ -101,7 +101,7 @@ Infisical supports two methods for connecting to Hashicorp Vault. - On self-hosted instances, simply copy your vault's base URL. (Ex. `https://vault.mycompany.com`) + On self-hosted instances, simply copy your vault's base URL. (Ex. `https://vault.example.com`) Save this value for later steps. @@ -159,7 +159,7 @@ Infisical supports two methods for connecting to Hashicorp Vault. "name": "my-vault-connection", "method": "app-role", "credentials": { - "instanceUrl": "https://vault.mycompany.com", + "instanceUrl": "https://vault.example.com", "roleId": "4797c4fa-7794-71f0-c8b1-7c87759df5bf", "secretId": "ad24df93-19c8-c865-9997-6b8513253d3a" } @@ -180,7 +180,7 @@ Infisical supports two methods for connecting to Hashicorp Vault. "app": "hashicorp-vault", "method": "app-role", "credentials": { - "instanceUrl": "https://vault.mycompany.com", + "instanceUrl": "https://vault.example.com", "roleId": "4797c4fa-7794-71f0-c8b1-7c87759df5bf" } } diff --git a/docs/integrations/secret-syncs/hashicorp-vault.mdx b/docs/integrations/secret-syncs/hashicorp-vault.mdx index d958085c50..403db8cf46 100644 --- a/docs/integrations/secret-syncs/hashicorp-vault.mdx +++ b/docs/integrations/secret-syncs/hashicorp-vault.mdx @@ -36,8 +36,8 @@ description: "Learn how to configure a Hashicorp Vault Sync for Infisical." ![Configure Destination](/images/secret-syncs/hashicorp-vault/sync-destination.png) - **Hashicorp Vault Connection**: The Vault Connection to authenticate with. - - **Secrets Engine Mount**: The Secrets Engine Mount to sync secrets to. - - **Path**: The Secrets Engine Mount path to sync secrets to. + - **Secrets Engine Mount**: The type of secrets engine to use (e.g., 'secret', 'kv'). + - **Path**: The specific path within the secrets engine where secrets will be stored. After configuring these parameters, click the **Next** button to continue to the Sync Options step. @@ -80,24 +80,24 @@ description: "Learn how to configure a Hashicorp Vault Sync for Infisical." ```bash Request curl --request POST \ - --url https://app.infisical.com/api/v1/secret-syncs/hashicorp-vault \ - --header 'Content-Type: application/json' \ - --data '{ - "name": "my-vault-sync", - "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", - "description": "an example sync", - "connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", - "environment": "dev", - "secretPath": "/", - "isEnabled": true, - "syncOptions": { - "initialSyncBehavior": "overwrite-destination" - }, - "destinationConfig": { - "mount": "secret", - "path": "dev/nested" - } - }' + --url https://app.infisical.com/api/v1/secret-syncs/hashicorp-vault \ + --header 'Content-Type: application/json' \ + --data '{ + "name": "my-vault-sync", + "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", + "description": "an example sync", + "connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a", + "environment": "dev", + "secretPath": "/", + "isEnabled": true, + "syncOptions": { + "initialSyncBehavior": "overwrite-destination" + }, + "destinationConfig": { + "mount": "secret", + "path": "dev/nested" + } + }' ``` ### Sample response diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HCVaultSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HCVaultSyncFields.tsx index ee0b7038f1..0865b81f36 100644 --- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HCVaultSyncFields.tsx +++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/HCVaultSyncFields.tsx @@ -29,6 +29,7 @@ export const HCVaultSyncFields = () => { { setValue("destinationConfig.mount", ""); + setValue("destinationConfig.path", ""); }} /> diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HCVaultConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HCVaultConnectionForm.tsx index 208d535fb8..2771d68eb7 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HCVaultConnectionForm.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HCVaultConnectionForm.tsx @@ -122,7 +122,7 @@ export const HCVaultConnectionForm = ({ appConnection, onSubmit }: Props) => { tooltipClassName="max-w-sm" tooltipText="The URL at which your Hashicorp Vault instance is hosted." > - + )} />