Skip to content

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

still lazy-create project if no user is associated with the bootstrap

Matheus Nogueira494eb9ab72e0
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index f6d7ab67b4..57a713c1ec 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -1032,7 +1032,7 @@ EE routes register before community routes so they can override/extend endpoints
**Agent Vault**: the same applies to the `agent-vault-*` services and routers; the concept map is [`src/ee/services/agent-vault/CLAUDE.md`](src/ee/services/agent-vault/CLAUDE.md). PAM and Agent Vault are the two **org-scoped products**: one implicit project per org, resolved lazily, whose roles collapse to admin or member. Anything that branches on `ProjectType.PAM` (metering emits, predefined roles, the billable-project count, invite grants) almost always needs an Agent Vault arm too.
-**Secret Scanning** is single-project (see the root `CLAUDE.md`): `secret-scanning-v2-project-bootstrap.ts` creates the project with the org (like PAM and Agent Vault), `secret-scanning-v2-project-resolver.ts` picks the active project and lazily creates it for older orgs, and routes that take `projectId` read `req.internalSecretScanningProjectId`.
+**Secret Scanning** is single-project (see the root `CLAUDE.md`): `secret-scanning-v2-project-bootstrap.ts` creates the project with the org when it has a creator to make admin (like PAM and Agent Vault), `secret-scanning-v2-project-resolver.ts` picks the active project and lazily creates it, with every org admin as project admin, for older orgs and for orgs created from the admin console, whose admins are only invited after the org exists, and routes that take `projectId` read `req.internalSecretScanningProjectId`.
**Dynamic secret lease secrets needed at revoke time go in `dynamic_secret_leases.encryptedLeaseData`**, never in `externalEntityId` or `config` (both plaintext, and `externalEntityId` is returned by every lease route and logged in audit events). A provider opts in by listing the `create()` `data` keys in `persistedLeaseFields`; the lease service encrypts them with the project's SecretManager key and every revoke path passes them back as `metadata.leaseData`. Lease routes return `SanitizedDynamicSecretLeaseSchema` so the column never reaches a response. Secret *config* fields are listed separately in `DYNAMIC_SECRET_SECRET_FIELDS` (`providers/redact.ts`), as dotted paths so nested secrets work (`clientAuth.clientSecret`): reads strip them via `redactStoredInputs`, and an update that omits one keeps the stored value via `restoreOmittedSecretFields`, because the update merge is shallow.
diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-project-bootstrap.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-project-bootstrap.ts
index 4ac3a95b5d..ebcd53df2a 100644
--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-project-bootstrap.ts
+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-project-bootstrap.ts
@@ -19,7 +19,8 @@ type TBootstrapInput = {
adminIdentityIds?: string[];
};
-// Orgs created before this existed get their project lazily from the secret scanning project resolver.
+// Orgs created before this existed, or created with no admin yet (the admin console), get their project
+// lazily from the secret scanning project resolver.
export const bootstrapSecretScanningProject = async (
{ orgId, adminUserIds = [], adminIdentityIds = [] }: TBootstrapInput,
{ projectDAL, membershipDAL, membershipRoleDAL }: TBootstrapDeps,
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index e5fdd17924..acff009f71 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -802,14 +802,18 @@ export const orgServiceFactory = ({
tx
);
- await bootstrapSecretScanningProject(
- {
- orgId: org.id,
- adminUserIds: userId ? [userId] : []
- },
- { projectDAL, membershipDAL, membershipRoleDAL },
- tx
- );
+ // Orgs created from the admin console have no creator; their admins are invited afterwards, so the
+ // project is left to the lazy resolver, which makes every org admin a project admin.
+ if (userId) {
+ await bootstrapSecretScanningProject(
+ {
+ orgId: org.id,
+ adminUserIds: [userId]
+ },
+ { projectDAL, membershipDAL, membershipRoleDAL },
+ tx
+ );
+ }
return org;
};