fix(membership): clean custom-resource policies when removing an org member - #1807
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughSummary by CodeRabbit
WalkthroughOrganization member-removal cascades now clean custom-resource policies through an injected resource service. Runtime wiring supplies that dependency, while the deleter no longer performs separate resource cleanup. ChangesMembership resource-policy cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 30243145128Coverage increased (+0.02%) to 46.909%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Tested end to end on a local serverDrove the real RPCs against a running Frontier with Postgres and SpiceDB, and checked all three places the state lives: the Setup
Grants before the removal:
What we didCalled What we got
Last-owner guardGave alice a grant on
Unit tests
One thing found on the side, not from this changeCreating a policy on a custom resource whose namespace has no The authz check on |
…member RemoveOrganizationMember deleted a member's org, project, and group policies but left their policies on custom resources in the org's projects untouched. The policy row and its SpiceDB rolebinding tuple stayed live, so an ex-member kept access to resources inside an org they had been removed from. Deleting that user later orphaned the policy row. The cascade now calls resource.RemovePrincipalAccess with the org's project IDs, after the last-owner guard so a rejected removal changes nothing. The deleter reaches the same cascade through ForceRemoveOrganizationMember, so its own call is no longer needed. Fixes #1801 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
061e811 to
0639730
Compare
Fixes #1801
Problem
When a member is removed from an organization, we delete their org, project, and group access. But we leave their access to custom resources inside that org's projects alone, in both the database and SpiceDB.
So a removed member keeps working access to resources in an org they are no longer part of. And if that user is deleted later, the leftover access row is never cleaned up, because by then they are not a member of any org.
Fix
The member removal now clears custom-resource access as well. It happens in one shared place, so every path that removes a member gets it — the API call, service user deletion, and user deletion.
The cleanup runs only after the last-owner check passes, so a rejected removal still changes nothing.
🤖 Generated with Claude Code