Skip to content

Removing a member from an org leaves their policies on disabled projects and groups #1980

Closed

Description

@rohilsurana

What happens

When a member, service user or group is removed from an organization, or a user is deleted, the policies of that principal in the org are supposed to be removed. Policies on disabled projects and disabled groups of the org are skipped. The principal keeps them.

Why

cascadeRemovePrincipal in core/membership/org.go sorts the principal's policies into org, project and group policies. It first builds sets of the org's project ids and group ids:

  • s.projectService.List(ctx, project.Filter{OrgID: orgID})
  • s.groupService.List(ctx, group.Filter{OrganizationID: orgID})

Both lists return only enabled rows when no state is set. A policy on a disabled project or group is not in either set, so it is never classified and never deleted.

Failure case

  1. A user has a role on a project in the org.
  2. The project is disabled.
  3. The user is removed from the org, or the user is deleted.
  4. The policy on the disabled project stays live, with its SpiceDB tuples.
  5. If the project is enabled again, the removed user has access again.

The same applies to a disabled group.

Expected

The cascade covers disabled projects and groups. List them in every state, the same way the organization delete now does (list enabled and disabled separately). Add a test with a disabled project and a disabled group.

Notes

  • Same behavior on main today. It is not new.
  • Found while reviewing the organization soft delete work. The org delete itself is not affected, because it removes every child project and group first.

Activity

  1. AmanGIT07 commented on Nov 17, 2026

    @AmanGIT07
    Contributor

    Fixed by #2049, now merged. Removing a member from an organization now also clears their policies and group memberships on disabled projects and groups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions