Skip to content

feat(BA-2476): apply RBAC validator for Project actions#10029

Merged
jopemachine merged 6 commits into
mainfrom
BA-2476
Mar 23, 2026
Merged

feat(BA-2476): apply RBAC validator for Project actions#10029
jopemachine merged 6 commits into
mainfrom
BA-2476

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented Mar 13, 2026

Summary

Applied RBAC validators to project (group) action processors following the established pattern from VFolder and Session services.

Changes:

  • Added ProjectScopeAction and ProjectSingleEntityAction base classes in services/group/actions/base.py
  • Refactored project actions to extend appropriate base classes and implement required RBAC methods (entity_type(), permission_operation_type(), scope_type(), target_entity_id())
  • Updated processors to use ScopeActionProcessor and SingleEntityActionProcessor with RBAC validators
  • Scope actions (create, search by domain/user) use validators.rbac.scope
  • Single-entity actions (get, modify, delete, purge) use validators.rbac.single_entity
  • Internal/admin actions remain on plain ActionProcessor without validators

Affected actions:

  • Scope: create_group, search_projects_by_domain, search_projects_by_user
  • Single-entity: get_project, modify_group, delete_group, purge_group
  • Internal/admin: usage_per_month, usage_per_period, search_projects

Test plan

  • pants fmt passes
  • pants fix passes
  • pants lint passes
  • All RBAC methods properly implemented
  • CI checks pass (type checking, tests)

Resolves BA-2476

Copilot AI review requested due to automatic review settings March 13, 2026 01:59
@github-actions github-actions Bot added size:M 30~100 LoC comp:manager Related to Manager component labels Mar 13, 2026
fregataa added a commit that referenced this pull request Mar 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Applies RBAC validators to the Group(Project) service action processors, aligning enforcement with the existing scoped vs single-entity action processor pattern used elsewhere in the codebase.

Changes:

  • Added ProjectScopeAction / ProjectSingleEntityAction (and result base types) to represent project-scoped actions in the group service.
  • Updated project search/get actions to inherit from the new Project* base classes (entity type now EntityType.PROJECT).
  • Updated GroupProcessors to attach RBAC scope/single-entity validators to relevant processors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/ai/backend/manager/services/group/processors.py Wires RBAC validators into scope and single-entity action processors for group/project operations.
src/ai/backend/manager/services/group/actions/search_projects.py Switches domain/user project search and project get actions/results to Project* base action types.
src/ai/backend/manager/services/group/actions/base.py Introduces ProjectScopeAction/ProjectSingleEntityAction base classes for project-typed actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ai/backend/manager/services/group/processors.py Outdated
fregataa added a commit that referenced this pull request Mar 13, 2026
@github-actions github-actions Bot added size:L 100~500 LoC and removed size:M 30~100 LoC labels Mar 13, 2026
@fregataa fregataa requested a review from a team March 13, 2026 08:44
@fregataa fregataa added this to the 26.3 milestone Mar 13, 2026
fregataa added a commit that referenced this pull request Mar 17, 2026
Comment thread tests/component/infra/conftest.py Outdated
from ai.backend.manager.services.user.service import UserService


def _create_mock_validators() -> ActionValidators:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same method exist in the tests/component/resource_preset/conftest.py

@jopemachine
Copy link
Copy Markdown
Member

jopemachine commented Mar 19, 2026

Is it intentional that both GroupSingleEntityAction and ProjectSingleEntityAction coexist? @fregataa
How are they different?

@HyeockJinKim
Copy link
Copy Markdown
Collaborator

Please rebase this PR. @fregataa

HyeockJinKim
HyeockJinKim previously approved these changes Mar 19, 2026
Copy link
Copy Markdown
Collaborator

@HyeockJinKim HyeockJinKim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please proceed with the follow-up tasks after the cleanup is complete. @fregataa

@fregataa fregataa modified the milestones: 26.3, 26.4 Mar 20, 2026
fregataa added a commit that referenced this pull request Mar 20, 2026
@github-actions github-actions Bot added size:M 30~100 LoC and removed size:L 100~500 LoC labels Mar 20, 2026
fregataa and others added 4 commits March 23, 2026 14:13
…ase classes

Add project-specific RBAC action base classes that return EntityType.PROJECT:
- ProjectScopeAction / ProjectScopeActionResult
- ProjectSingleEntityAction / ProjectSingleEntityActionResult

These will be used by project-related actions to properly implement RBAC validation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… ProjectSingleEntityAction bases

Classify and refactor project-related actions in search_projects.py:
- SearchProjectsByDomainAction → ProjectScopeAction
- SearchProjectsByUserAction → ProjectScopeAction
- GetProjectAction → ProjectSingleEntityAction
- SearchProjectsAction remains as GroupAction (admin/internal)

All RBAC methods (scope_type, scope_id, target_entity_id, target_element)
already implemented correctly.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add RBAC validators to ScopeActionProcessor and SingleEntityActionProcessor
for project-related actions in the group service.

Changes:
- Pass validators.rbac.scope to ScopeActionProcessor for:
  - create_group, search_projects_by_domain, search_projects_by_user
- Pass validators.rbac.single_entity to SingleEntityActionProcessor for:
  - modify_group, delete_group, purge_group, get_project
- Internal/admin actions (usage_per_month, usage_per_period, search_projects)
  remain on plain ActionProcessor without RBAC validators

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
fregataa and others added 2 commits March 23, 2026 14:13
Search actions are excluded from RBAC validator scope per BA-2946.
Search results are already filtered by scope through the existing
SearchScope mechanism.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fregataa
Copy link
Copy Markdown
Member Author

Is it intentional that both GroupSingleEntityAction and ProjectSingleEntityAction coexist? @fregataa How are they different?

ProjectAction is correct. I will clean up this by creating an another issue

@fregataa fregataa requested a review from a team March 23, 2026 05:14
@jopemachine jopemachine merged commit 95992c9 into main Mar 23, 2026
30 checks passed
@jopemachine jopemachine deleted the BA-2476 branch March 23, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants