Skip to content

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

fix: add manage-access check on folder move and edi

adilson3174d85752ac
diff --git a/backend/e2e-test/routes/v2/secret-folder-rbac.spec.ts b/backend/e2e-test/routes/v2/secret-folder-rbac.spec.ts
index a26d143835..57b15f7c1c 100644
--- a/backend/e2e-test/routes/v2/secret-folder-rbac.spec.ts
+++ b/backend/e2e-test/routes/v2/secret-folder-rbac.spec.ts
@@ -40,6 +40,8 @@ const orgId = seedData1.organization.id;
// permission evaluation runs against a dedicated member user created in beforeAll
let memberUserId: string;
let memberMembershipId: string;
+let memberJwtToken: string;
+const memberSessionId = randomUUID();
let permissionArg: {
actor: ActorType;
@@ -132,14 +134,41 @@ beforeAll(async () => {
);
folderDataKey = KeyStorePrefixes.ProjectFolderPermissionData(projectId, ActorType.USER, memberUserId);
folderMarkerKey = KeyStorePrefixes.ProjectFolderPermissionMarker(projectId, ActorType.USER, memberUserId);
+
+ await testDb(TableName.AuthTokenSession).insert({
+ id: memberSessionId,
+ userId: memberUserId,
+ ip: "127.0.0.1",
+ userAgent: "e2e-folder-rbac",
+ accessVersion: 1,
+ refreshVersion: 1,
+ lastUsed: new Date()
+ } as never);
+
+ memberJwtToken = jwt.sign(
+ {
+ authTokenType: AuthTokenType.ACCESS_TOKEN,
+ userId: memberUserId,
+ tokenVersionId: memberSessionId,
+ authMethod: AuthMethod.EMAIL,
+ organizationId: orgId,
+ accessVersion: 1
+ },
+ getConfig().AUTH_SECRET,
+ { expiresIn: 3600 }
+ );
});
afterAll(async () => {
await testRedis.del(permissionDataKey, permissionMarkerKey, folderDataKey, folderMarkerKey);
+ await testDb(TableName.AuthTokenSession).where({ id: memberSessionId }).del();
await testDb(TableName.Membership).where({ actorUserId: memberUserId }).del();
await testDb(TableName.Users).where({ id: memberUserId }).del();
});
+const clearMemberPermissionCaches = () =>
+ testRedis.del(permissionDataKey, permissionMarkerKey, folderDataKey, folderMarkerKey);
+
const createFolder = async (dto: { path: string; name: string }) => {
const res = await testServer.inject({
method: "POST",
@@ -392,12 +421,6 @@ describe("Folder deletion reaps folder-scoped privileges", () => {
});
describe("Folder deletion requires manage-access on RBAC-granted folders", () => {
- let memberJwtToken: string;
- const memberSessionId = randomUUID();
-
- const clearMemberPermissionCaches = () =>
- testRedis.del(permissionDataKey, permissionMarkerKey, folderDataKey, folderMarkerKey);
-
const deleteFolderAs = async (token: string, dto: { path: string; id: string; forceDelete?: boolean }) =>
testServer.inject({
method: "DELETE",
@@ -411,33 +434,7 @@ describe("Folder deletion requires manage-access on RBAC-granted folders", () =>
}
});
- beforeAll(async () => {
- await testDb(TableName.AuthTokenSession).insert({
- id: memberSessionId,
- userId: memberUserId,
- ip: "127.0.0.1",
- userAgent: "e2e-folder-rbac",
- accessVersion: 1,
- refreshVersion: 1,
- lastUsed: new Date()
- } as never);
-
- memberJwtToken = jwt.sign(
- {
- authTokenType: AuthTokenType.ACCESS_TOKEN,
- userId: memberUserId,
- tokenVersionId: memberSessionId,
- authMethod: AuthMethod.EMAIL,
- organizationId: orgId,
- accessVersion: 1
- },
- getConfig().AUTH_SECRET,
- { expiresIn: 3600 }
- );
- });
-
afterAll(async () => {
- await testDb(TableName.AuthTokenSession).where({ id: memberSessionId }).del();
await clearMemberPermissionCaches();
});
@@ -515,6 +512,32 @@ describe("Folder deletion requires manage-access on RBAC-granted folders", () =>
await clearMemberPermissionCaches();
});
+ test("allows deletion when the only grant on the folder has expired", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-guard-expired" });
+
+ // nothing reaps expired rows, and permission evaluation drops them, so the guard must too
+ await testDb(TableName.AdditionalPrivilege).insert({
+ name: "e2e-rbac-guard-expired",
+ actorUserId: memberUserId,
+ projectId,
+ folderId: folder.id,
+ role: SecretFolderRole.Read,
+ permissions: null,
+ isTemporary: true,
+ temporaryAccessStartTime: new Date(Date.now() - 7_200_000),
+ temporaryAccessEndTime: new Date(Date.now() - 3_600_000)
+ });
+
+ try {
+ await clearMemberPermissionCaches();
+ const res = await deleteFolderAs(memberJwtToken, { path: "/", id: folder.id });
+ expect(res.statusCode).toBe(200);
+ } finally {
+ await testDb(TableName.AdditionalPrivilege).where({ name: "e2e-rbac-guard-expired" }).del();
+ await clearMemberPermissionCaches();
+ }
+ });
+
test("blocks an identity without manage-access from deleting a folder that has a grant", async () => {
const identityName = `rbac-guard-identity-${alphaNumericNanoId(8)}`.toLowerCase();
const [identity] = await testDb(TableName.Identity).insert({ name: identityName, orgId }).returning("*");
@@ -583,6 +606,216 @@ describe("Folder deletion requires manage-access on RBAC-granted folders", () =>
});
});
+describe("Folder move and rename require manage-access on RBAC-granted folders", () => {
+ const moveFolderAs = (token: string, dto: { folderId: string; destinationPath: string }) =>
+ testServer.inject({
+ method: "POST",
+ url: `/api/v2/folders/move`,
+ headers: { authorization: `Bearer ${token}` },
+ body: {
+ projectId,
+ folderId: dto.folderId,
+ destinationEnvironment: seedData1.environment.slug,
+ destinationPath: dto.destinationPath
+ }
+ });
+
+ const renameFolderAs = (token: string, dto: { id: string; path: string; name: string; description?: string }) =>
+ testServer.inject({
+ method: "PATCH",
+ url: `/api/v2/folders/${dto.id}`,
+ headers: { authorization: `Bearer ${token}` },
+ body: {
+ projectId,
+ environment: seedData1.environment.slug,
+ path: dto.path,
+ name: dto.name,
+ description: dto.description
+ }
+ });
+
+ const renameFolderBatchAs = (token: string, dto: { id: string; path: string; name: string }) =>
+ testServer.inject({
+ method: "PATCH",
+ url: `/api/v2/folders/batch`,
+ headers: { authorization: `Bearer ${token}` },
+ body: {
+ projectId,
+ folders: [{ id: dto.id, environment: seedData1.environment.slug, path: dto.path, name: dto.name }]
+ }
+ });
+
+ const grantFolderRole = (dto: { name: string; folderId: string; role: SecretFolderRole }) =>
+ testDb(TableName.AdditionalPrivilege).insert({
+ name: dto.name,
+ actorUserId: memberUserId,
+ projectId,
+ folderId: dto.folderId,
+ role: dto.role,
+ permissions: null,
+ isTemporary: false
+ });
+
+ afterAll(async () => {
+ await clearMemberPermissionCaches();
+ });
+
+ test("blocks a member without manage-access from moving a folder that has a grant", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-move-src" });
+ const destination = await createFolder({ path: "/", name: "rbac-move-dest" });
+
+ try {
+ await grantFolderRole({ name: "e2e-rbac-move", folderId: folder.id, role: SecretFolderRole.Read });
+ await clearMemberPermissionCaches();
+
+ const res = await moveFolderAs(memberJwtToken, { folderId: folder.id, destinationPath: "/rbac-move-dest" });
+ expect(res.statusCode).toBe(403);
+ expect(res.json().message).toContain("manage folder access");
+
+ const [privilege] = await testDb(TableName.AdditionalPrivilege).where({ name: "e2e-rbac-move" });
+ expect(privilege.folderId).toBe(folder.id);
+ } finally {
+ await deleteFolder({ path: "/", id: folder.id, forceDelete: true });
+ await deleteFolder({ path: "/", id: destination.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("blocks a member without manage-access from moving a parent whose descendant has a grant", async () => {
+ const parent = await createFolder({ path: "/", name: "rbac-move-parent" });
+ const child = await createFolder({ path: "/rbac-move-parent", name: "rbac-move-child" });
+ const destination = await createFolder({ path: "/", name: "rbac-move-parent-dest" });
+
+ try {
+ await grantFolderRole({ name: "e2e-rbac-move-child", folderId: child.id, role: SecretFolderRole.Read });
+ await clearMemberPermissionCaches();
+
+ const res = await moveFolderAs(memberJwtToken, {
+ folderId: parent.id,
+ destinationPath: "/rbac-move-parent-dest"
+ });
+ expect(res.statusCode).toBe(403);
+ expect(res.json().message).toContain("manage folder access");
+ } finally {
+ await deleteFolder({ path: "/", id: parent.id, forceDelete: true });
+ await deleteFolder({ path: "/", id: destination.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("allows a member to move a folder with no grants", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-move-free" });
+ const destination = await createFolder({ path: "/", name: "rbac-move-free-dest" });
+
+ try {
+ await clearMemberPermissionCaches();
+ const res = await moveFolderAs(memberJwtToken, {
+ folderId: folder.id,
+ destinationPath: "/rbac-move-free-dest"
+ });
+ expect(res.statusCode).toBe(200);
+ } finally {
+ await deleteFolder({ path: "/", id: destination.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("blocks a member without manage-access from renaming a folder that has a grant", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-rename-src" });
+
+ try {
+ await grantFolderRole({ name: "e2e-rbac-rename", folderId: folder.id, role: SecretFolderRole.Read });
+ await clearMemberPermissionCaches();
+
+ const res = await renameFolderAs(memberJwtToken, {
+ id: folder.id,
+ path: "/",
+ name: "rbac-rename-src-renamed"
+ });
+ expect(res.statusCode).toBe(403);
+ expect(res.json().message).toContain("manage folder access");
+ } finally {
+ await deleteFolder({ path: "/", id: folder.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("blocks the batch route from renaming a folder that has a grant", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-rename-batch" });
+
+ try {
+ await grantFolderRole({ name: "e2e-rbac-rename-batch", folderId: folder.id, role: SecretFolderRole.Read });
+ await clearMemberPermissionCaches();
+
+ const res = await renameFolderBatchAs(memberJwtToken, {
+ id: folder.id,
+ path: "/",
+ name: "rbac-rename-batch-renamed"
+ });
+ expect(res.statusCode).toBe(403);
+ expect(res.json().message).toContain("manage folder access");
+ } finally {
+ await deleteFolder({ path: "/", id: folder.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("allows a description-only update on a granted folder, since no path moves", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-rename-desc" });
+
+ try {
+ await grantFolderRole({ name: "e2e-rbac-rename-desc", folderId: folder.id, role: SecretFolderRole.Read });
+ await clearMemberPermissionCaches();
+
+ const res = await renameFolderAs(memberJwtToken, {
+ id: folder.id,
+ path: "/",
+ name: "rbac-rename-desc",
+ description: "updated by a member without manage-access"
+ });
+ expect(res.statusCode).toBe(200);
+ } finally {
+ await deleteFolder({ path: "/", id: folder.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+
+ test("lets the full-access tier rename its own granted folder but not move it elsewhere", async () => {
+ const folder = await createFolder({ path: "/", name: "rbac-relocate-full" });
+ const destination = await createFolder({ path: "/", name: "rbac-relocate-full-dest" });
+
+ try {
+ await grantFolderRole({
+ name: "e2e-rbac-relocate-full",
+ folderId: folder.id,
+ role: SecretFolderRole.FullAccess
+ });
+ await clearMemberPermissionCaches();
+
+ // the tier confers manage-access at the folder's own path, which is the only scope a rename changes
+ const renamed = await renameFolderAs(memberJwtToken, {
+ id: folder.id,
+ path: "/",
+ name: "rbac-relocate-full-renamed"
+ });
+ expect(renamed.statusCode).toBe(200);
+
+ // a move needs manage-access at the destination too, which the tier does not confer
+ await clearMemberPermissionCaches();
+ const moved = await moveFolderAs(memberJwtToken, {
+ folderId: folder.id,
+ destinationPath: "/rbac-relocate-full-dest"
+ });
+ expect(moved.statusCode).toBe(403);
+ expect(moved.json().message).toContain("manage folder access");
+ } finally {
+ await deleteFolder({ path: "/", id: folder.id, forceDelete: true });
+ await deleteFolder({ path: "/", id: destination.id, forceDelete: true });
+ await clearMemberPermissionCaches();
+ }
+ });
+});
+
describe("Permission audit endpoint folder grants", () => {
test("includeFolderPermissions=false excludes folder grants from audit sources", async () => {
const folder = await createFolder({ path: "/", name: "rbac-audit" });
diff --git a/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts b/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts
index fcc783c38e..5d7d4ed5fa 100644
--- a/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts
+++ b/backend/src/ee/services/secret-approval-policy/secret-approval-policy-service.ts
@@ -1,4 +1,5 @@
import { ForbiddenError } from "@casl/ability";
+import { Knex } from "knex";
import picomatch from "picomatch";
import { ActionProjectType } from "@app/db/schemas";
@@ -620,14 +621,14 @@ export const secretApprovalPolicyServiceFactory = ({
return sapPolicies;
};
- const findEnvPolicies = async (projectId: string, environment: string) => {
- const env = await projectEnvDAL.findOne({ slug: environment, projectId });
+ const findEnvPolicies = async (projectId: string, environment: string, tx?: Knex) => {
+ const env = await projectEnvDAL.findOne({ slug: environment, projectId }, tx);
if (!env) {
throw new NotFoundError({
message: `Environment with slug '${environment}' not found in project with ID ${projectId}`
});
}
- return secretApprovalPolicyDAL.find({ deletedAt: null }, { envId: env.id });
+ return secretApprovalPolicyDAL.find({ deletedAt: null }, { envId: env.id }, tx);
};
const getSecretApprovalPolicy = async (projectId: string, environment: string, path: string) => {
@@ -638,9 +639,14 @@ export const secretApprovalPolicyServiceFactory = ({
// batched variant of getSecretApprovalPolicy: fetches the env policies once, then matches every supplied path in
// memory. returns a Map keyed by the original input path, containing only paths governed by a policy.
- const getSecretApprovalPolicyByPaths = async (projectId: string, environment: string, secretPaths: string[]) => {
+ const getSecretApprovalPolicyByPaths = async (
+ projectId: string,
+ environment: string,
+ secretPaths: string[],
+ tx?: Knex
+ ) => {
const policyByPath = new Map<string, Awaited<ReturnType<typeof secretApprovalPolicyDAL.find>>[number]>();
- const policies = await findEnvPolicies(projectId, environment);
+ const policies = await findEnvPolicies(projectId, environment, tx);
if (!policies.length) return policyByPath;
for (const path of secretPaths) {
diff --git a/backend/src/services/secret-folder/secret-folder-fns.ts b/backend/src/services/secret-folder/secret-folder-fns.ts
index 39d11f6018..89d1573a33 100644
--- a/backend/src/services/secret-folder/secret-folder-fns.ts
+++ b/backend/src/services/secret-folder/secret-folder-fns.ts
@@ -162,7 +162,7 @@ export const canActorReadBlock = (
// absolute path of a subtree folder, re-rooted at `rootFolderPath`; the moved folder itself is "/". when the
// root is "/", its prefix is dropped so child paths stay "/child" rather than "//child".
-const buildToAbsPath = (rootFolderPath: string) => (folderPath: string) => {
+export const buildToAbsPath = (rootFolderPath: string) => (folderPath: string) => {
if (folderPath === "/") return rootFolderPath;
const prefix = rootFolderPath === "/" ? "" : rootFolderPath;
return `${prefix}${folderPath}`;
@@ -262,7 +262,8 @@ export const checkFolderMovePolicyBlock = async (
environment: string;
rootFolderPath: string;
},
- { secretApprovalPolicyService }: TCheckFolderMovePolicyBlockDeps
+ { secretApprovalPolicyService }: TCheckFolderMovePolicyBlockDeps,
+ tx?: Knex
): Promise<TFolderMoveBlock | null> => {
const toAbsPath = buildToAbsPath(rootFolderPath);
@@ -271,7 +272,8 @@ export const checkFolderMovePolicyBlock = async (
const policyByPath = await secretApprovalPolicyService.getSecretApprovalPolicyByPaths(
projectId,
environment,
- subtreeAbsPaths
+ subtreeAbsPaths,
+ tx
);
// report the first blocked path in subtree order, matching the previous per-folder behavior.
diff --git a/backend/src/services/secret-folder/secret-folder-service.ts b/backend/src/services/secret-folder/secret-folder-service.ts
index a58633abed..36557a88c4 100644
--- a/backend/src/services/secret-folder/secret-folder-service.ts
+++ b/backend/src/services/secret-folder/secret-folder-service.ts
@@ -3,11 +3,12 @@ import { ForbiddenError, MongoAbility, MongoQuery, subject } from "@casl/ability
import { Knex } from "knex";
import path from "path";
import { v4 as uuidv4, validate as uuidValidate } from "uuid";
+import { logger } from "@app/lib/logger";
import { ActionProjectType, TProjectEnvironments, TSecretFoldersInsert } from "@app/db/schemas";
import { TDynamicSecretDALFactory } from "@app/ee/services/dynamic-secret/dynamic-secret-dal";
import { THoneyTokenDALFactory } from "@app/ee/services/honey-token/honey-token-dal";
-import { validateSecretMovePermissions } from "@app/ee/services/permission/permission-fns";
+import { isActiveRole, validateSecretMovePermissions } from "@app/ee/services/permission/permission-fns";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
ProjectPermissionActions,
@@ -31,6 +32,7 @@ import {
assertFolderMoveAllowed,
buildChildrenMap,
buildFolderPath,
+ buildToAbsPath,
canActorReadBlock,
checkFolderMoveBlock,
checkFolderMovePolicyBlock,
@@ -152,6 +154,69 @@ export const secretFolderServiceFactory = ({
reminderService,
keyStore
}: TSecretFolderServiceFactoryDep) => {
+ const $findGrantedFolderIds = async (projectId: string, folderIds: string[], tx?: Knex) => {
+ if (!folderIds.length) return new Set<string>();
+
+ const grants = await additionalPrivilegeDAL.find({ projectId, $in: { folderId: folderIds } }, { tx });
+ return new Set(
+ grants.filter((grant) => grant.role && isActiveRole(grant)).map((grant) => grant.folderId as string)
+ );
+ };
+
+ const $assertFolderGrantsRelocatable = async (
+ {
+ projectId,
+ permission,
+ operation,
+ relocations
+ }: {
+ projectId: string;
+ permission: MongoAbility<ProjectPermissionSet, MongoQuery>;
+ operation: "move" | "rename";
+ relocations: { folderId: string; managePaths: { environment: string; secretPath: string }[] }[];
+ },
+ tx?: Knex
+ ) => {
+ const grantedFolderIds = await $findGrantedFolderIds(
+ projectId,
+ relocations.map((relocation) => relocation.folderId),
+ tx
+ );
+ if (!grantedFolderIds.size) return;
+
+ const blocked = relocations.find(
+ (relocation) =>
+ grantedFolderIds.has(relocation.folderId) &&
+ relocation.managePaths.some(({ environment, secretPath }) =>
+ permission.cannot(
+ ProjectPermissionSecretFolderActions.ManageAccess,
+ subject(ProjectPermissionSub.SecretFolders, { environment, secretPath })
+ )
+ )
+ );
+ if (blocked) {
+ logger.info(blocked, "adilson blocked!!!!");
+ logger.info(relocations, "adilson relocations!!!!");
+ const requiredPaths = blocked.managePaths.map(({ secretPath }) => `'${secretPath}'`).join(" and ");
+ throw new ForbiddenRequestError({
+ message: `Cannot ${operation} this folder: the folder at path '${blocked.managePaths[0].secretPath}' has access permissions assigned to users or identities. You need permission to manage folder access on ${requiredPaths} to ${operation} it.`
+ });
+ }
+ };
+
+ const $buildSubtreeRelocations = async (
+ { folderId, environment, folderPath }: { folderId: string; environment: string; folderPath: string },
+ tx: Knex
+ ) => {
+ const subtree = await folderDAL.findByEnvsDeep({ parentIds: [folderId] }, tx);
+ const toAbsPath = buildToAbsPath(folderPath);
+
+ return subtree.map((folder) => ({
+ folderId: folder.id,
+ managePaths: [{ environment, secretPath: toAbsPath(folder.path) }]
+ }));
+ };
+
const createFolder = async ({
projectId,
actor,
@@ -416,6 +481,19 @@ export const secretFolderServiceFactory = ({
name: "Batch update folder"
});
}
+
+ await $assertFolderGrantsRelocatable(
+ {
+ projectId: projectId as string,
+ permission,
+ operation: "rename",
+ relocations: await $buildSubtreeRelocations(
+ { folderId: folder.id, environment, folderPath: path.join(secretPath, folder.name) },
+ tx
+ )
+ },
+ tx
+ );
}
const [doc] = await folderDAL.update(
@@ -556,6 +634,21 @@ export const secretFolderServiceFactory = ({
});
}
+ if (name !== folder.name) {
+ await $assertFolderGrantsRelocatable(
+ {
+ projectId,
+ permission,
+ operation: "rename",
+ relocations: await $buildSubtreeRelocations(
+ { folderId: folder.id, environment, folderPath: path.join(secretPath, folder.name) },
+ tx
+ )
+ },
+ tx
+ );
+ }
+
const [doc] = await folderDAL.update(
{ envId: env.id, id: folder.id, parentId: parentFolder.id, isReserved: false },
{ name, description },
@@ -668,11 +761,11 @@ export const secretFolderServiceFactory = ({
id: folder.id
}));
- const folderGrants = await additionalPrivilegeDAL.find(
- { projectId, $in: { folderId: folderPolicyPaths.map((p) => p.id) } },
- { tx }
+ const grantedFolderIds = await $findGrantedFolderIds(
+ projectId,
+ folderPolicyPaths.map((p) => p.id),
+ tx
);
- const grantedFolderIds = new Set(folderGrants.map((grant) => grant.folderId));
const unmanageableGrant = folderPolicyPaths.find(
(folderPolicyPath) =>
grantedFolderIds.has(folderPolicyPath.id) &&
@@ -701,11 +794,13 @@ export const secretFolderServiceFactory = ({
});
const folderIdsWithSecrets = new Set(secrets.map((s) => s.folderId));
const pathsWithSecrets = folderPolicyPaths.filter((p) => folderIdsWithSecrets.has(p.id));
+ if (!pathsWithSecrets.length) return;
const policyByPath = await secretApprovalPolicyService.getSecretApprovalPolicyByPaths(
projectId,
env.slug,
- pathsWithSecrets.map((p) => p.path)
+ pathsWithSecrets.map((p) => p.path),
+ tx
);
for (const folderPolicyPath of pathsWithSecrets) {
@@ -1555,14 +1650,16 @@ export const secretFolderServiceFactory = ({
);
const sourcePolicyBlock = await checkFolderMovePolicyBlock(
{ subtree, projectId, environment: sourceEnvironment, rootFolderPath: sourceFolderPath },
- folderMoveBlockDeps
+ folderMoveBlockDeps,
+ tx
);
const sourceBlock = secretTypeBlock ?? sourcePolicyBlock;
const destinationBlock = destination
? await checkFolderMovePolicyBlock(
{ subtree, projectId, environment: destination.environment, rootFolderPath: destination.path },
- folderMoveBlockDeps
+ folderMoveBlockDeps,
+ tx
)
: null;
@@ -1818,6 +1915,7 @@ export const secretFolderServiceFactory = ({
: (idBySourceFolderId.get(f.parentId as string) as string);
return {
newFolderId: idBySourceFolderId.get(f.id) as string,
+ sourceFolderId: f.id,
name: f.name,
description: f.description,
depth: f.depth,
@@ -1865,6 +1963,19 @@ export const secretFolderServiceFactory = ({
});
}
+ await $assertFolderGrantsRelocatable(
+ {
+ projectId,
+ permission,
+ operation: "move",
+ relocations: plan.map((entry) => ({
+ folderId: entry.sourceFolderId,
+ managePaths: [{ environment: sourceEnvironment, secretPath: entry.sourceAbsPath }]
+ }))
+ },
+ tx
+ );
+
// 6. recreate the folder tree at the destination. inserting root-first satisfies the self-referencing
// parentId FK; each new folder also gets a version row and an ADD commit (mirrors createManyFolders).
const newFolderRows: TSecretFoldersInsert[] = plan.map((entry) => ({
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/RemoveFolderAccessDialog.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/RemoveFolderAccessDialog.tsx
index 8fb2ea6f64..7043bb9414 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/RemoveFolderAccessDialog.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/FolderAccessSheet/RemoveFolderAccessDialog.tsx
@@ -59,7 +59,7 @@ export const RemoveFolderAccessDialog = ({
return (
<AlertDialog open={isOpen} onOpenChange={onOpenChange}>
- <AlertDialogContent className="sm:max-w-xl">
+ <AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove Folder Access</AlertDialogTitle>
<AlertDialogDescription>