Skip to content

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

Merge branch 'main' into feat/adilsitos/secrets-495

adilsond88a90ae0821
diff --cc backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
index 39104634e5,1ff4644ebe..c98100a7b8
--- a/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
+++ b/backend/src/services/secret-validation-rule/secret-validation-rule-service.ts
@@@ -1,11 -1,14 +1,15 @@@
import { ForbiddenError } from "@casl/ability";
import { Knex } from "knex";
+import picomatch from "picomatch";
- import { ActionProjectType, TSecretValidationRules } from "@app/db/schemas";
+ import { ActionProjectType } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
- import { ProjectPermissionActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
- import { NotFoundError } from "@app/lib/errors";
+ import {
+ ProjectPermissionSecretValidationRuleActions,
+ ProjectPermissionSub
+ } from "@app/ee/services/permission/project-permission";
+ import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
+ import { OrgServiceActor } from "@app/lib/types";
import { TProjectEnvDALFactory } from "@app/services/project-env/project-env-dal";
import { TKmsServiceFactory } from "../kms/kms-service";
diff --cc docs/documentation/platform/external-migrations/vault.mdx
index 6bed99b287,1e6cc4ef8e..7b3e979681
--- a/docs/documentation/platform/external-migrations/vault.mdx
+++ b/docs/documentation/platform/external-migrations/vault.mdx
@@@ -143,62 -134,30 +143,62 @@@ KV secrets are imported into a specifi
</Info>
<Warning>
- If your Vault token is restricted and cannot list a mount from its root,
- If your Vault token is restricted and can't list a mount from its root, Infisical discovers the available secret paths from the token's resultant ACL (`sys/internal/ui/resultant-acl`). Any path that contains a `+` wildcard (Vault's single-segment wildcard, e.g. `secret/+/db`) can't be expanded and is **skipped**, i.e., those secrets won't be imported. To migrate them, grant the token access to the explicit KV paths instead of relying on `+`.
++ If your Vault token is restricted and can't list a mount from its root,
+ Infisical discovers the available secret paths from the token's resultant ACL
+ (`sys/internal/ui/resultant-acl`). Any path that contains a `+` wildcard
- (Vault's single-segment wildcard, e.g. `secret/+/db`) cannot be expanded and
- is **skipped**, i.e., those secrets will not be imported. To migrate them,
- grant the token access to the explicit KV paths instead of relying on `+`.
++ (Vault's single-segment wildcard, e.g. `secret/+/db`) can't be expanded and is
++ **skipped**, i.e., those secrets won't be imported. To migrate them, grant the
++ token access to the explicit KV paths instead of relying on `+`.
</Warning>
**To import secrets from Vault:**
1. Navigate to your project and select a specific environment (e.g., Development, Production)
- 2. In the secrets view, click the dropdown icon (caret) next to the **"+ Add Secret"** button
+ 2. In the secrets view, select the dropdown icon (caret) next to the **"+ Add Secret"** button
- ![Add Secret Dropdown](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-caret.png)
-
+ ![Add Secret Dropdown](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-caret.png)
3. Select **"Add from HashiCorp Vault"**
- ![Add Secret Dropdown](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-option.png)
-
+ ![Add Secret Dropdown](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-option.png)
-4. In the modal, pick the **App Connection** (project- or organization-scoped Vault connections both appear here), then the **Vault namespace**, then the **Secrets Engine** (KV mount), and finally one or more **Vault secret paths** to import (for example, `secret/app/prod`). Keys are copied using their names from Vault.
-<Note>
- If you select multiple paths and the same key name exists in more than one of them, the import aborts and no secrets are saved.
-</Note>
+4. Pick the **App Connection**, then the **Namespace**, then the **Secrets Engine** that holds the paths you want, and finally one or more entries under **Vault Secret Path**. Keys are copied using their names from Vault.
+
+5. (Optional) Select **"Preserve folder structure"** to recreate each Vault path as a folder in Infisical. Leave it unchecked to copy every key from every selected path into the folder you are currently viewing.
+
+ <Note>
+ Importing without preserving the structure aborts if the same key name
+ exists in more than one selected path, and no secrets are saved. Preserving
+ the structure resolves the conflict, because each Vault path gets its own
+ folder.
+ </Note>
+
+6. Check the **Preview** to confirm where every secret will land, then click **"Import Secrets"**
+
+The secrets are imported into the environment and folder path you are currently viewing. You can select up to 25 Vault paths per import.
+
+#### Preserving your Vault folder structure
-5. Select **"Import Secrets"**
- ![Import Vault Secrets](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-modal.png)
+With **"Preserve folder structure"** enabled, each Vault path becomes its own [folder](/documentation/platform/folder), nested under your current path. Otherwise, all selected secrets are imported into the current folder.
+The preview reflects the choice, so you can compare both before importing:
-The secrets will be imported into your current environment and folder path. If your Vault path has nested paths, you can create [folders](/documentation/platform/folder) in Infisical to maintain a similar structure.
+<Tabs>
+ <Tab title="Flattened">
+ Every key lands directly in the folder you are viewing. This import runs from
+ the project root, so all six secrets collapse into `/` and the Vault path each
+ one came from is shown only for reference.
+
+ ![Vault import preview without preserving the folder structure](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-flattened.png)
+
+ </Tab>
+ <Tab title="Structure preserved">
+ Each Vault path becomes a folder. This import runs from `/newww`, so
+ `team-a/service-1`, `team-a/service-2`, and `team-b` are recreated beneath it,
+ each holding the secrets from its own Vault path.
+
+ ![Vault import preview with the folder structure preserved](/images/platform/external-migrations/vault-in-platform/import-vault-secrets-preserve-structure.png)
+
+ </Tab>
+</Tabs>
### Migrating Kubernetes auth method
@@@ -253,8 -212,8 +253,8 @@@ The form will be automatically populate
- Token audiences
<Note>
- Sensitive values like cluster tokens cannot be retrieved from Vault and must
- Sensitive values like cluster tokens can't be retrieved from Vault and must
-- be manually provided in the form after loading the configuration.
++ Sensitive values like cluster tokens can't be retrieved from Vault and must be
++ manually provided in the form after loading the configuration.
</Note>
<Tip>