Skip to content

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

fix: only check for delete protection if deleting org identity, not sub-org identity membership

Scott Wilsond026de4ec106
diff --git a/backend/src/services/identity/identity-service.ts b/backend/src/services/identity/identity-service.ts
index d9baaa2f5f..cf8d185c07 100644
--- a/backend/src/services/identity/identity-service.ts
+++ b/backend/src/services/identity/identity-service.ts
@@ -329,14 +329,14 @@ export const identityServiceFactory = ({
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);
- if (identityOrgMembership.identity.hasDeleteProtection)
- throw new BadRequestError({ message: "Identity has delete protection" });
-
if (identityOrgMembership.identity.projectId) {
throw new BadRequestError({ message: `Identity is managed by project` });
}
if (identityOrgMembership.identity.orgId === actorOrgId) {
+ if (identityOrgMembership.identity.hasDeleteProtection)
+ throw new BadRequestError({ message: "Identity has delete protection" });
+
const deletedIdentity = await identityDAL.deleteById(id);
await licenseService.updateSubscriptionOrgMemberCount(identityOrgMembership.scopeOrgId);
return { ...deletedIdentity, orgId: identityOrgMembership.scopeOrgId };