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
feat: enhance role validation and structure in identity services
Victor Hugo dos Santos8250611a068c
diff --git a/backend/src/server/routes/v1/project-identity-router.ts b/backend/src/server/routes/v1/project-identity-router.tsindex 691b21f80b..6581b2284d 100644--- a/backend/src/server/routes/v1/project-identity-router.ts+++ b/backend/src/server/routes/v1/project-identity-router.ts@@ -63,11 +63,11 @@ export const registerProjectIdentityRouter = async (server: FastifyZodProvider).array(z.union([z.object({- role: z.string(),+ role: z.string().min(1),isTemporary: z.literal(false).default(false)}),z.object({- role: z.string(),+ role: z.string().min(1),isTemporary: z.literal(true),temporaryMode: z.nativeEnum(TemporaryPermissionMode),temporaryRange: z.string().refine((val) => ms(val) > 0, "Temporary range must be a positive number"),@@ -109,7 +109,17 @@ export const registerProjectIdentityRouter = async (server: FastifyZodProvider)name: req.body.name,hasDeleteProtection: req.body.hasDeleteProtection,metadata: req.body.metadata,- roles: req.body.roles?.map(({ role, isTemporary }) => ({ role, isTemporary }))+ roles: req.body.roles?.map((r) =>+ r.isTemporary+ ? {+ role: r.role,+ isTemporary: r.isTemporary,+ temporaryMode: r.temporaryMode,+ temporaryRange: r.temporaryRange,+ temporaryAccessStartTime: r.temporaryAccessStartTime+ }+ : { role: r.role, isTemporary: r.isTemporary }+ )}}});diff --git a/backend/src/services/identity-v2/identity-service.ts b/backend/src/services/identity-v2/identity-service.tsindex 7a9b3e3c2c..5c960ea16a 100644--- a/backend/src/services/identity-v2/identity-service.ts+++ b/backend/src/services/identity-v2/identity-service.ts@@ -154,7 +154,7 @@ export const identityV2ServiceFactory = ({scopeData.projectId);for (const permissionRole of permissionRoles) {- if (permissionRole?.role?.name !== ProjectMembershipRole.NoAccess) {+ if (permissionRole?.role?.slug !== ProjectMembershipRole.NoAccess) {const permissionBoundary = validatePrivilegeChangeOperation(shouldUseNewPrivilegeSystem,[ProjectPermissionIdentityActions.AssignRole, ProjectPermissionIdentityActions.GrantPrivileges],