feat: enforce PAT scope intersection on ByCurrentUser queries#1447
feat: enforce PAT scope intersection on ByCurrentUser queries#1447
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR refactors principal handling by introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
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 |
Pull Request Test Coverage Report for Build 22997983984Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
core/project/service_test.go (1)
601-603: Add a non-empty group case to this PAT +NonInheritedtest.Returning
[]group.Group{}here means this scenario only covers direct user policies. It still doesn't pin the new branch where non-inherited project IDs come from the resolved user's group memberships and are intersected with PAT scope afterward, so a regression there would still pass.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fd1b06f2-940c-445d-8eca-7d1b3116a4fb
📒 Files selected for processing (17)
core/authenticate/authenticate.gocore/group/service.gocore/group/service_test.gocore/invitation/mocks/group_service.gocore/invitation/service.gocore/organization/service.gocore/organization/service_test.gocore/project/mocks/group_service.gocore/project/service.gocore/project/service_test.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/group_service.gointernal/api/v1beta1connect/mocks/project_service.gointernal/api/v1beta1connect/serviceuser.gointernal/api/v1beta1connect/serviceuser_test.gointernal/api/v1beta1connect/user.gointernal/api/v1beta1connect/user_test.go
Description
When a request is authenticated via a Personal Access Token (PAT), the
*ByCurrentUserRPCs (ListOrganizationsByCurrentUser,ListCurrentUserGroups,ListProjectsByCurrentUser) now enforce the PAT's resource scope. TheListByUserservice methods resolve the PAT to its underlying user for SpiceDB lookups, then intersect the results with the PAT's scoped resources — returning only what's accessible by both the user and the PAT.Changes
string) to (principal authenticate.Principal).
Tests