feat: ListCurrentUserPAT RPC with RQL support by AmanGIT07 · Pull Request #1449 · raystack/frontier
📝 Walkthrough
Summary by CodeRabbit
Release Notes
New Features
- Added capability to list personal access tokens with advanced filtering, sorting, and pagination support
- Personal access tokens now display associated role and project information for enhanced scope visibility
Walkthrough
This PR introduces a complete listing capability for Personal Access Tokens (PATs) with RQL-based filtering and pagination. Changes encompass service layer enhancements with scope enrichment (RoleIDs/ProjectIDs), repository-level RQL support, new API handlers, authorization validation, protobuf definitions, and supporting mock infrastructure across the stack.
Changes
| Cohort / File(s) | Summary |
|---|---|
Core PAT Models core/userpat/models/pat.go |
Added RoleIDs and ProjectIDs fields to PAT struct; introduced new PATList struct containing PATs slice and pagination metadata. |
Service Layer Interfaces & Implementations core/userpat/service.go, core/userpat/userpat.go, internal/api/v1beta1connect/interfaces.go |
Added List method to PolicyService interface; implemented List on Service with scope enrichment via enrichWithScope; added List to Repository and UserPATService interfaces. |
Service Mock Infrastructure core/userpat/mocks/policy_service.go, core/userpat/mocks/repository.go, internal/api/v1beta1connect/mocks/user_pat_service.go |
Generated mock implementations for List methods with Run, Return, and RunAndReturn helper methods across PolicyService, Repository, and UserPATService mocks. |
Repository Implementation internal/store/postgres/userpat_repository.go |
Implemented List method with RQL filtering, searching, and pagination support; added helpers buildPATFilteredQuery, countPATs, and applySort for composing dynamic queries. |
API Handler internal/api/v1beta1connect/user_pat.go |
Implemented ListCurrentUserPATs HTTP handler with validation and error handling; extended transformPATToPB to populate RoleIds and ProjectIds fields. |
Authorization & Interceptors pkg/server/connect_interceptors/authorization.go |
Added authorization validation entry for ListCurrentUserPATsProcedure, checking GetPermission on OrganizationNamespace. |
Protobuf RPC Definitions proto/v1beta1/frontierv1beta1connect/frontier.connect.go |
Added ListCurrentUserPATs and GetCurrentUserPAT RPCs with client and server wiring, procedure constants, and unimplemented handlers. |
Protobuf Validation proto/v1beta1/frontier.pb.validate.go |
Generated Validate and ValidateAll methods for message types with validation error types and multi-error handling for runtime constraint validation. |
Build Configuration Makefile |
Updated PROTON_COMMIT constant to latest version. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
- feat: PAT authentication chain, token validation, and error handling #1442: Overlapping changes in core/userpat domain types and repository mock infrastructure
- feat: CreateCurrentUserPAT RPC implementation #1401: Related modifications to userpat service behavior and policy grant semantics
Suggested reviewers
- rohilsurana
- whoAbhishekSah
📝 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.