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
add policy to enable/disable feature in org
Matheus Nogueiraa16d1716e9c8
diff --git a/backend/src/db/migrations/20260625000000_allow-cross-project-secret-sharing.ts b/backend/src/db/migrations/20260625000000_allow-cross-project-secret-sharing.tsnew file mode 100644index 0000000000..abcbb2e103--- /dev/null+++ b/backend/src/db/migrations/20260625000000_allow-cross-project-secret-sharing.ts@@ -0,0 +1,21 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "allowCrossProjectSecretSharing");+ if (!hasColumn) {+ await knex.schema.table(TableName.Organization, (table) => {+ table.boolean("allowCrossProjectSecretSharing").notNullable().defaultTo(false);+ });+ }+}++export async function down(knex: Knex): Promise<void> {+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "allowCrossProjectSecretSharing");+ if (hasColumn) {+ await knex.schema.table(TableName.Organization, (table) => {+ table.dropColumn("allowCrossProjectSecretSharing");+ });+ }+}diff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.tsindex 76ad1aa180..5a1b2489e5 100644--- a/backend/src/db/schemas/organizations.ts+++ b/backend/src/db/schemas/organizations.ts@@ -42,6 +42,7 @@ export const OrganizationsSchema = z.object({parentOrgId: z.string().uuid().nullable().optional(),rootOrgId: z.string().uuid().nullable().optional(),blockDuplicateSecretSyncDestinations: z.boolean().default(false),+ allowCrossProjectSecretSharing: z.boolean().default(false),secretShareBrandConfig: z.unknown().nullable().optional(),defaultCertManagerProjectId: z.string().nullable().optional()});diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.tsindex 682c54f63f..4ddbb7f4d1 100644--- a/backend/src/server/routes/v1/organization-router.ts+++ b/backend/src/server/routes/v1/organization-router.ts@@ -397,6 +397,10 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {.boolean().optional().describe("Block duplicate secret sync destinations across the organization"),+ allowCrossProjectSecretSharing: z+ .boolean()+ .optional()+ .describe("Allow secret imports and references to target secrets in other projects within the organization"),secretShareBrandConfig: z.object({primaryColor: zdiff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.tsindex 2f81669baa..0be629e055 100644--- a/backend/src/services/org/org-schema.ts+++ b/backend/src/services/org/org-schema.ts@@ -31,6 +31,7 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({maxSharedSecretLifetime: true,maxSharedSecretViewLimit: true,blockDuplicateSecretSyncDestinations: true,+ allowCrossProjectSecretSharing: true,rootOrgId: true,parentOrgId: true,secretShareBrandConfig: truediff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.tsindex 3e2cb9e8a8..beeda2a4fc 100644--- a/backend/src/services/org/org-service.ts+++ b/backend/src/services/org/org-service.ts@@ -84,6 +84,7 @@ import {TUpgradePrivilegeSystemDTO,TVerifyUserToOrgDTO} from "./org-types";+import { canUseCrossProjectSecretSharing } from "../project-grant/project-grant-fns";type TOrgServiceFactoryDep = {userAliasDAL: Pick<TUserAliasDALFactory, "delete">;@@ -434,6 +435,7 @@ export const orgServiceFactory = ({maxSharedSecretLifetime,maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,+ allowCrossProjectSecretSharing,secretShareBrandConfig}}: TUpdateOrgDTO) => {@@ -618,6 +620,8 @@ export const orgServiceFactory = ({});}+ const crossProjectSecretSharingEnabled = canUseCrossProjectSecretSharing(orgId) && allowCrossProjectSecretSharing+const org = await orgDAL.updateById(orgId, {name,slug: slug ? slugify(slug) : undefined,@@ -639,6 +643,7 @@ export const orgServiceFactory = ({maxSharedSecretLifetime,maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,+ allowCrossProjectSecretSharing: crossProjectSecretSharingEnabled,secretShareBrandConfig});if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });@@ -879,10 +884,10 @@ export const orgServiceFactory = ({typeof isActive === "undefined"? [foundMembership]: await orgDAL.updateMembership(- { id: membershipId, scopeOrgId: orgId, scope: AccessScope.Organization },- { isActive },- tx- );+ { id: membershipId, scopeOrgId: orgId, scope: AccessScope.Organization },+ { isActive },+ tx+ );if (userRole) {await membershipRoleDAL.delete({ membershipId }, tx);await membershipRoleDAL.create(diff --git a/backend/src/services/org/org-types.ts b/backend/src/services/org/org-types.tsindex 6fa3f15950..c98ae63d5e 100644--- a/backend/src/services/org/org-types.ts+++ b/backend/src/services/org/org-types.ts@@ -102,6 +102,7 @@ export type TUpdateOrgDTO = {maxSharedSecretLifetime: number;maxSharedSecretViewLimit: number | null;blockDuplicateSecretSyncDestinations: boolean;+ allowCrossProjectSecretSharing: boolean;secretShareBrandConfig: TSecretShareBrandConfig;}>;} & TOrgPermission;diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsxindex 67e0007c3b..7ab91cdaa8 100644--- a/frontend/src/hooks/api/organization/queries.tsx+++ b/frontend/src/hooks/api/organization/queries.tsx@@ -170,6 +170,7 @@ export const useUpdateOrg = () => {maxSharedSecretLifetime,maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,+ allowCrossProjectSecretSharing,secretShareBrandConfig}) => {return apiRequest.patch(`/api/v1/organization/${orgId}`, {@@ -193,6 +194,7 @@ export const useUpdateOrg = () => {maxSharedSecretLifetime,maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,+ allowCrossProjectSecretSharing,secretShareBrandConfig});},diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.tsindex 44e2f6e96a..38326ca847 100644--- a/frontend/src/hooks/api/organization/types.ts+++ b/frontend/src/hooks/api/organization/types.ts@@ -36,6 +36,7 @@ export type Organization = {maxSharedSecretLifetime: number;maxSharedSecretViewLimit: number | null;blockDuplicateSecretSyncDestinations: boolean;+ allowCrossProjectSecretSharing: boolean;parentOrgId: string | null;rootOrgId: string | null;secretShareBrandConfig?: TSecretShareBrandConfig;@@ -63,6 +64,7 @@ export type UpdateOrgDTO = {maxSharedSecretViewLimit?: number | null;maxSharedSecretLifetime?: number;blockDuplicateSecretSyncDestinations?: boolean;+ allowCrossProjectSecretSharing?: boolean;secretShareBrandConfig?: TSecretShareBrandConfig;};diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/ProductSettingsPage.tsx b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/ProductSettingsPage.tsxindex e45618204a..294c072b8a 100644--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/ProductSettingsPage.tsx+++ b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/ProductSettingsPage.tsx@@ -17,7 +17,7 @@ import {FieldTitle,Switch} from "@app/components/v3";-import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization, useServerConfig } from "@app/context";import { useUpdateOrg } from "@app/hooks/api/organization/queries";import { ProjectType } from "@app/hooks/api/projects/types";@@ -27,6 +27,7 @@ import { ProjectTemplatesSection } from "./project-templates/ProjectTemplatesSecexport const ProductSettingsPage = () => {const { currentOrg } = useOrganization();const { mutateAsync: updateOrg, isPending } = useUpdateOrg();+ const { config } = useServerConfig();const handleToggle = async (state: boolean) => {if (!currentOrg?.id) return;@@ -42,6 +43,20 @@ export const ProductSettingsPage = () => {});};+ const handleCrossProjectSharingToggle = async (state: boolean) => {+ if (!currentOrg?.id) return;++ await updateOrg({+ orgId: currentOrg.id,+ allowCrossProjectSecretSharing: state+ });++ createNotification({+ text: `Successfully ${state ? "enabled" : "disabled"} cross-project secret sharing for this organization`,+ type: "success"+ });+ };+return (<><Helmet>@@ -91,6 +106,29 @@ export const ProductSettingsPage = () => {)}</OrgPermissionCan></Field>+ {config.isCrossProjectSecretSharingEnabled && <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>Cross-project secret sharing</FieldTitle>+ <FieldDescription>+ When enabled, allows secret imports and secret references to target folders+ and secrets from other projects within the same organization.+ </FieldDescription>+ </FieldContent>+ <OrgPermissionCan+ I={OrgPermissionActions.Edit}+ a={OrgPermissionSubjects.Settings}+ >+ {(isAllowed) => (+ <Switch+ id="allow-cross-project-secret-sharing"+ variant="project"+ checked={currentOrg?.allowCrossProjectSecretSharing ?? false}+ onCheckedChange={(value) => handleCrossProjectSharingToggle(value)}+ disabled={!isAllowed || isPending}+ />+ )}+ </OrgPermissionCan>+ </Field>}</FieldGroup></CardContent></Card>