Skip to content

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

patch project identity update

Maidul Islam74fe673724b7
diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js
index b23cf05ae3..1b8f846104 100644
--- a/backend/.eslintrc.js
+++ b/backend/.eslintrc.js
@@ -38,6 +38,7 @@ module.exports = {
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"no-void": "off",
+ "no-await-in-loop": "off",
"consistent-return": "off", // my style
"import/order": "off", // for simple-import-order
"import/prefer-default-export": "off", // why
diff --git a/backend/src/services/identity-project/identity-project-service.ts b/backend/src/services/identity-project/identity-project-service.ts
index 18a1803ac0..0cc47a8946 100644
--- a/backend/src/services/identity-project/identity-project-service.ts
+++ b/backend/src/services/identity-project/identity-project-service.ts
@@ -82,6 +82,7 @@ export const identityProjectServiceFactory = ({
role,
project.id
);
+
const hasPriviledge = isAtLeastAsPrivileged(permission, rolePermission);
if (!hasPriviledge)
throw new ForbiddenRequestError({
@@ -135,16 +136,18 @@ export const identityProjectServiceFactory = ({
message: `Identity with id ${identityId} doesn't exists in project with id ${projectId}`
});
- const { permission: identityRolePermission } = await permissionService.getProjectPermission(
- ActorType.IDENTITY,
- projectIdentity.identityId,
- projectIdentity.projectId,
- actorAuthMethod,
- actorOrgId
- );
- const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
- if (!hasRequiredPriviledges)
- throw new ForbiddenRequestError({ message: "Failed to delete more privileged identity" });
+ for (const { role: requestedRoleChange } of roles) {
+ const { permission: rolePermission } = await permissionService.getProjectPermissionByRole(
+ requestedRoleChange,
+ projectId
+ );
+
+ const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, rolePermission);
+
+ if (!hasRequiredPriviledges) {
+ throw new ForbiddenRequestError({ message: "Failed to change to a more privileged role" });
+ }
+ }
// validate custom roles input
const customInputRoles = roles.filter(