mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 18:27:19 +00:00
fix: resolved edge case in folder empty action
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
import { PROJECT_ROLE } from "@app/lib/api-docs";
|
import { PROJECT_ROLE } from "@app/lib/api-docs";
|
||||||
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { SanitizedRoleSchema } from "@app/server/routes/sanitizedSchemas";
|
import { SanitizedRoleSchemaV1 } from "@app/server/routes/sanitizedSchemas";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
||||||
@@ -50,7 +50,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
role: SanitizedRoleSchema
|
role: SanitizedRoleSchemaV1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -110,7 +110,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
role: SanitizedRoleSchema
|
role: SanitizedRoleSchemaV1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,7 +153,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
role: SanitizedRoleSchema
|
role: SanitizedRoleSchemaV1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -219,7 +219,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
|||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
role: SanitizedRoleSchema
|
role: SanitizedRoleSchemaV1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -768,10 +768,14 @@ export const backfillPermissionV1SchemaToV2Schema = (data: z.infer<typeof Projec
|
|||||||
subject: ProjectPermissionSub.SecretImports as const
|
subject: ProjectPermissionSub.SecretImports as const
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const secretFolderPolicies = secretSubjects.map(({ subject, ...el }) => ({
|
const secretFolderPolicies = secretSubjects
|
||||||
...el,
|
.map(({ subject, ...el }) => ({
|
||||||
subject: ProjectPermissionSub.SecretFolders
|
...el,
|
||||||
}));
|
// read permission is not needed anymore
|
||||||
|
action: el.action.filter((caslAction) => caslAction !== ProjectPermissionActions.Read),
|
||||||
|
subject: ProjectPermissionSub.SecretFolders
|
||||||
|
}))
|
||||||
|
.filter((el) => el.action?.length > 0);
|
||||||
|
|
||||||
const dynamicSecretPolicies = secretSubjects.map(({ subject, ...el }) => {
|
const dynamicSecretPolicies = secretSubjects.map(({ subject, ...el }) => {
|
||||||
const action = el.action.map((e) => {
|
const action = el.action.map((e) => {
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ export const SanitizedRoleSchema = ProjectRolesSchema.extend({
|
|||||||
permissions: UnpackedPermissionSchema.array()
|
permissions: UnpackedPermissionSchema.array()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const SanitizedRoleSchemaV1 = ProjectRolesSchema.extend({
|
||||||
|
permissions: UnpackedPermissionSchema.array().transform((el) =>
|
||||||
|
el.filter(
|
||||||
|
(i) =>
|
||||||
|
![ProjectPermissionSub.DynamicSecrets, ProjectPermissionSub.SecretImports].includes(
|
||||||
|
(i?.subject as ProjectPermissionSub) || ""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
export const SanitizedDynamicSecretSchema = DynamicSecretsSchema.omit({
|
export const SanitizedDynamicSecretSchema = DynamicSecretsSchema.omit({
|
||||||
inputIV: true,
|
inputIV: true,
|
||||||
inputTag: true,
|
inputTag: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user