fix(org): support machine identity actors on org membership update/delete endpoints - #7785
Conversation
…lete endpoints Co-Authored-By: ashwin <ashwin@infisical.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
| Filename | Overview |
|---|---|
| backend/src/server/routes/v2/organization-router.ts | Removes user-only no-op guards and forwards the authenticated actor context to all three membership mutation services. |
| backend/src/services/org/org-service.ts | Authorizes membership mutations using the actual actor while preserving user-only self-update and self-removal protections. |
| backend/src/services/org/org-types.ts | Replaces user-specific mutation DTO fields with the shared actor-aware organization permission contract. |
Reviews (1): Last reviewed commit: "fix(org): support machine identity actor..." | Re-trigger Greptile
Context
Customer report:
DELETE /api/v2/organizations/{orgId}/memberships/{membershipId}returned200with an empty body, but the user was never removed.Root cause: the v2 org membership
PATCH,DELETE, and bulkDELETEroutes advertiseIDENTITY_ACCESS_TOKENinverifyAuth, but their handlers began with:so any call authenticated with a machine identity token silently no-oped and returned
200with an empty response — the delete never ran.Fix: thread the real actor through instead of hard-coding
ActorType.USER:TUpdateOrgMembershipDTO/TDeleteOrgMembershipDTO/TDeleteOrgMembershipsDTOnow extendTOrgPermission(actor+actorIdinstead ofuserId)updateOrgMembership/deleteOrgMembership/bulkDeleteOrgMembershipspassactor/actorIdtogetOrgPermission, so machine identities go through the normal CASL org-permission check (Edit/DeleteonMember)Cannot update own organization membership, self-delete checks) only apply when the actor is a userMachine identities with the appropriate org Member permissions can now actually update/delete user memberships; identities without permission get a proper
403instead of a fake200.Steps to verify the change
DELETE /api/v2/organizations/{orgId}/memberships/{membershipId}with the identity access token → membership is deleted and returned in the response.403.Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).Link to Devin session: https://app.devin.ai/sessions/fbf6011cd8a744f897de3650f9e35316
Requested by: @ashwin-infisical