feat(membership): add group membership management#1596
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (12)
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 25720876539Coverage increased (+0.3%) to 42.352%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Manual Testing Results - SetGroupMemberRole RPCTested with multiple users and groups using the frontier-test CLI. Test Environment
Happy Path Tests
Unhappy Path Tests
Authorization Tests
Validation Tests
SpiceDB Relation Sync Tests
Summary
The SpiceDB relation sync tests confirm that both policy and relation are updated atomically when roles change, fixing the leaky-relation issue. |
Introduces the SetGroupMemberRole RPC and three service methods on the membership package: AddGroupMember, SetGroupMemberRole, and OnGroupCreated. These manage policy + SpiceDB relation atomically and keep them in sync, fixing the leaky-relation pattern at the group layer. - AddGroupMember validates org membership of the principal and rejects duplicates with ErrAlreadyMember (service-only, no proto). - SetGroupMemberRole rejects non-members with ErrNotMember and enforces a min-owner constraint (ErrLastGroupOwnerRole) on demotion. - OnGroupCreated bundles the group<->org hierarchy relations with the initial owner add, so group.Create can wire SpiceDB with one call. - Principal validation is restricted to app/user; the switch is kept extensible for future principal types. Audit events are added for both the added and role-changed cases. No call sites are migrated yet — group.Create, AddGroupUsers, and the deletion of legacy group service methods will follow in subsequent PRs. PROTON_COMMIT is temporarily pinned to the feature-branch SHA on raystack/proton#485; it will be re-pinned to the merge commit once that PR lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The authorization interceptor denies any procedure not in its map. Without this entry the new RPC returned PermissionDenied at the interceptor before reaching the handler. Uses GroupNamespace + UpdatePermission, matching AddGroupUsers/RemoveGroupUser. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ca8efde to
05c5097
Compare
raystack/proton#485 has merged. Re-pin from the feature-branch SHA to the merge commit on proton main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Adds the
SetGroupMemberRoleRPC and three new service methods on the membership package that fix the long-standing leaky-relation issue for groups by managing policy and SpiceDB relation in sync.AddGroupMember(groupID, principalID, principalType, roleID)— service-only (no proto). Validates the principal is a member of the group's parent org, rejects existing members withErrAlreadyMember, creates policy + matchinggroup#owner/group#memberrelation, falling back to delete the policy if relation creation fails.SetGroupMemberRole(...)— service + RPC. Rejects non-members withErrNotMember, enforces min-owner constraint (ErrLastGroupOwnerRole) on demotion, replaces both policy and relation atomically (matches the org pattern in Add SetOrganizationMemberRole RPC to replace client-side policy manipulation #1459).OnGroupCreated(groupID, orgID, creatorID, creatorType)— service-only. Bundlesgroup#org@organization+organization#member@group#memberhierarchy relations with the initial owner add, so futuregroup.Createcan wire SpiceDB through one call.Design notes
app/userfor groups today. The switch invalidateGroupPrincipalis structured so addingapp/serviceuserlater is a one-case change with no API impact.pkg/auditrecordandcore/audit.group.Create,AddGroupUsers, and the deletion ofgroup.addOwner/AddMember/AddUsers/addMemberPolicyfollow in subsequent PRs to keep each diff reviewable.Why this is safe to land alone
AddGroupUsers/group creation behavior are untouched.Test plan
go build ./...go test ./core/membership/... ./internal/api/v1beta1connect/... ./core/audit/... ./pkg/auditrecord/...OnGroupCreated.SetGroupMemberRole.gofmt -lclean on changed files.Follow-ups (separate PRs)
group.CreatetoOnGroupCreated; deletegroup.addOwner/addAsOrgMember/addOrgToGroup.AddGroupUsershandler to loopAddGroupMember; deletegroup.AddMember/AddUsers/addMemberPolicy.