feat: validate user project access during PAT Create and Update by AmanGIT07 · Pull Request #1487 · raystack/frontier

Warning

Rate limit exceeded

@AmanGIT07 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 32 seconds.

⌛ 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: 5c1911b6-a11c-48d6-9df9-12755aac88e6

📥 Commits

Reviewing files that changed from the base of the PR and between 94cc5c4 and d199676.

📒 Files selected for processing (2)
  • core/userpat/mocks/project_service.go
  • core/userpat/service_test.go
📝 Walkthrough

Walkthrough

This PR adds project-access validation to the user personal access token service. It introduces a ProjectService dependency to verify users have access to requested projects, implements validation logic in the PAT service, and updates handlers and tests to support the new validation flow.

Changes

Cohort / File(s) Summary
Project Access Validation
core/userpat/service.go, core/userpat/errors/errors.go, internal/api/v1beta1connect/user_pat.go
Added ProjectService interface and validateProjectAccess function to validate user project access before PAT creation/update; new ErrProjectForbidden error constant; handlers map this error to connect.CodeInvalidArgument.
Dependency Wiring
cmd/serve.go
Reordered userpat.NewService instantiation to add projectService dependency parameter after projectService construction.
Tests
core/userpat/service_test.go
Extended test helper to create project service mock; updated all NewService calls with project service argument; added new TestService_ValidateProjectAccess test suite covering project access validation, allowed/rejected scenarios, and all-projects scope bypass.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • whoAbhishekSah
  • rohilsurana

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.