Skip to content

fix(permission): tool manager must not inherit manage_tool_owner (IKABS3) - #2355

Open
yaojin3616 wants to merge 1 commit into
mainfrom
fix/ikabs3-tool-manager-cannot-delete-owner
Open

fix(permission): tool manager must not inherit manage_tool_owner (IKABS3)#2355
yaojin3616 wants to merge 1 commit into
mainfrom
fix/ikabs3-tool-manager-cannot-delete-owner

Conversation

@yaojin3616

Copy link
Copy Markdown
Collaborator

根因

  • 工具权限模板 default_permission_ids_for_relation 采用「按关系等级累加」的通用算法,所有 can_manage 级权限的等级相同,导致「管理者」也会被默认授予 manage_tool_owner
  • ResourceAuthorizationService._can_grant_modelmanage_tool_owner 已在调用方权限集时允许 owner 关系的 grant/revoke。
  • 前端权限弹窗据此展示「所有者」行的删除(移除)入口,使「管理者」看上去可以删除「所有者」。

修复

  • tool_permission_template.py:将 default_permission_ids_for_relation 改为显式分层表(与 channel_permission_template 保持一致),「管理者」只继承 manage_tool_managermanage_tool_viewer,不再包含 manage_tool_owner;「所有者」仍然拥有全部三项 manage_tool_*
  • 资源授权的 _can_grant_model 校验逻辑保持不变。

验证

  • test/permission/test_permission_relation_defaults.py::test_tool_permission_defaults_accept_computed_relations 调整断言,新增对「管理者不含 manage_tool_owner」「所有者仍含全部 manage_*」的回归断言。
  • test/permission/test_resource_authorization_service.py 新增 test_manager_cannot_revoke_tool_owner_grant,钉死「管理者」的默认权限集与 _can_grant_model('tool', 'owner', owner_model, manager_perm) 行为,确保后续回归可被 CI 捕获。
  • 手动调用 default_permission_ids_for_relation('manager') 验证:返回 {edit_tool, manage_tool_manager, manage_tool_viewer, use_tool, view_tool},不再含 manage_tool_owner

影响范围

  • 本次只修工具(tool)模板;同样的「按等级累加」模式也出现在 application_permission_template(workflow/assistant)与 knowledge_library_permission_template,属于同类隐患但不在本工单范围内,后续单独跟进。
  • 历史已存在的「管理者-工具」绑定如果已经带上了 manage_tool_owner,本次代码修复不会回收其既有权限(绑定数据未变),仅阻断新写入。

关联

…BS3)

The tool permission template's `default_permission_ids_for_relation` used a
generic level-based calculation that handed a manager the `manage_tool_owner`
permission (same can_manage level as `manage_tool_manager`). The
authorization service then accepted a manager's revoke of an owner-tier
grant, and the permission dialog's "manage" dropdown surfaced the owner
row's delete action, so a manager could remove an owner's permission on a
tool.

Switch the tool template to an explicit per-tier default (mirroring
channel_permission_template) so a manager only inherits
`manage_tool_manager` and `manage_tool_viewer`. The owner tier still
receives all three `manage_tool_*` permissions, and the underlying
`_can_grant_model` check is unchanged. Update the related default test
and add a regression test that pins both the manager's permission set
and the authorize-side guard.

Refs: gitee IKABS3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant