feat: implement GetCurrentUserPAT RPC by AmanGIT07 · Pull Request #1450 · raystack/frontier
Warning
Rate limit exceeded
@AmanGIT07 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 40 seconds before requesting another review.
⌛ How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.
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 configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 292f4000-37df-4346-92eb-59005c4e498d
📒 Files selected for processing (5)
core/userpat/service.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/user_pat_service.gointernal/api/v1beta1connect/user_pat.gopkg/server/connect_interceptors/authorization.go
📝 Walkthrough
Walkthrough
This PR adds a Get method to retrieve a specific Personal Access Token by user ID and PAT ID. Changes include service layer implementation with scope enrichment for RoleIDs and ProjectIDs from SpiceDB policies, API interface and handler updates with error mapping, and corresponding test coverage across layers.
Changes
| Cohort / File(s) | Summary |
|---|---|
Build Configuration Makefile |
Updated PROTON_COMMIT hash from e5878c3 to 2416855, affecting protobuf artifact fetching during proto generation. |
Mock Generation core/userpat/mocks/policy_service.go, internal/api/v1beta1connect/mocks/user_pat_service.go |
Added mock methods (List and Get respectively) with testify mock infrastructure, including Call types, Expecter methods, and fluent configuration methods (Run, Return, RunAndReturn). |
Model Updates core/userpat/models/pat.go |
Added RoleIDs and ProjectIDs fields to PAT struct with JSON serialization tags. |
Service Layer core/userpat/service.go, core/userpat/service_test.go |
Implemented Service.Get method with ownership verification and scope enrichment via internal enrichWithScope helper; added PolicyService.List method; comprehensive test coverage for Get scenarios including disabled feature, not found, ownership checks, and enrichment failures. |
API Interface & Handler internal/api/v1beta1connect/interfaces.go, internal/api/v1beta1connect/user_pat.go, internal/api/v1beta1connect/user_pat_test.go |
Added UserPATService.Get interface method; implemented GetCurrentUserPAT handler with error mapping to Connect error codes (PermissionDenied, InvalidArgument, NotFound, FailedPrecondition, Internal); updated transformPATToPB to populate RoleIds and ProjectIds fields; added handler test suite covering authentication, permissions, and field transformation. |
Authorization pkg/server/connect_interceptors/authorization.go |
Added GetCurrentUserPAT to authorizationSkipEndpoints map to bypass authorization checks. |
Generated Code proto/v1beta1/frontier.pb.validate.go, proto/v1beta1/frontierv1beta1connect/frontier.connect.go |
Added validation methods (Validate and ValidateAll) for protobuf messages with error types and multi-error aggregation; wired ListCurrentUserPATs and GetCurrentUserPAT RPC procedures with client and handler implementations in Connect framework. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~35 minutes
Possibly related PRs
- feat: PAT authentication chain, token validation, and error handling #1442 — Directly related PAT codepath modifications including endpoint additions, model/validator changes, and Connect handler wiring.
- feat: CreateCurrentUserPAT RPC implementation #1401 — Implements PAT functionality across the same layers (RPC handlers, frontier.connect.go, API interfaces/mocks, core/userpat service and mocks).
- feat: enforce PAT scope on permission checks #1446 — Adds PAT Get/GetByID methods and wiring in core/userpat service and API handlers with mock support.
Suggested reviewers
- rohilsurana
- rsbh
📝 Coding Plan
- Generate coding plan for human review comments
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 @coderabbitai help to get the list of available commands and usage tips.
Tip
CodeRabbit can generate a title for your PR based on the changes.
Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.