feat: ListCurrentUserPAT RPC with RQL support #1449
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbitRelease NotesNew Features
WalkthroughThis 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
📝 Coding Plan
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 23050230356Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/store/postgres/userpat_repository.go (1)
213-227: Consider validating sort column names against an allowlist.The
applySortfunction passessortItem.Namedirectly togoqu.C()without validating it against a list of allowed sortable columns. While RQL validation occurs at the API layer against the model struct, adding validation here would provide defense-in-depth, especially since the PR mentionslast_used_atis sortable but it's not inpatRQLFilterSupportedColumns.♻️ Suggested improvement
+var patRQLSortSupportedColumns = []string{"id", "title", "expires_at", "created_at", "last_used_at"} + func (r UserPATRepository) applySort(query *goqu.SelectDataset, rqlQuery *rql.Query) *goqu.SelectDataset { if len(rqlQuery.Sort) > 0 { for _, sortItem := range rqlQuery.Sort { + if !slices.Contains(patRQLSortSupportedColumns, sortItem.Name) { + continue // skip invalid sort columns + } switch sortItem.Order { case "desc": query = query.OrderAppend(goqu.C(sortItem.Name).Desc()) default: query = query.OrderAppend(goqu.C(sortItem.Name).Asc()) } } } else { query = query.Order(goqu.C("created_at").Desc()) } return query }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dd38e0c5-5827-4f42-97a6-bff0181705fe
⛔ Files ignored due to path filters (2)
proto/v1beta1/frontier.pb.gois excluded by!**/*.pb.goproto/v1beta1/models.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (13)
Makefilecore/userpat/mocks/policy_service.gocore/userpat/mocks/repository.gocore/userpat/models/pat.gocore/userpat/service.gocore/userpat/userpat.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/user_pat_service.gointernal/api/v1beta1connect/user_pat.gointernal/store/postgres/userpat_repository.gopkg/server/connect_interceptors/authorization.goproto/v1beta1/frontier.pb.validate.goproto/v1beta1/frontierv1beta1connect/frontier.connect.go
Description:
Summary
ListCurrentUserPATsRPC to list PATs for the authenticated user within an orgrole_idsandproject_ids.GetPermissionon the org) for the RPCManual tests:
grpcurl ListCurrentUserPATswith no query returns all PATs with default paginationeq,likeon titleidandtitlecreated_at,expires_at,last_used_atoffset,limit,total_countrole_idsandproject_idsare correctly populated[]not error