feat(permissions): implement fine-grained permission control#386
Open
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Open
feat(permissions): implement fine-grained permission control#386Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Conversation
- Add read_users and write_users fields to Meta for path-level access control - Rename 'write' permission to 'write_content' for clarity - Convert Meta.write field to write_content_bypass flag with caution warning - Update permission checks across toolbar, context menu, and editor components - Add user selector in Meta management UI for granular permission assignment - Refactor permission logic: operations require (userCan || bypass) && pathAllowed - Improve code consistency using userCan() helper instead of manual index lookups Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description / 描述
This PR introduces a comprehensive fine-grained permission control system, allowing administrators to configure path-level access control with user-specific read/write
permissions.
本 PR 引入了全面的细粒度权限控制系统,允许管理员配置路径级访问控制,支持基于用户的读写权限。
Key Changes / 主要变更
paths.
新增用户级路径权限:在 Meta 配置中引入 read_users 和 write_users 字段,使管理员能够指定哪些用户可以访问特定路径。
重命名权限以提高清晰度:将通用的 write 权限更改为 write_content,以更好地反映其用途(创建/上传/修改内容)。
operations without user permission checks.
重构旧版写入标志:将 Meta 的 write 字段转换为 write_content_bypass,以向后兼容历史行为,即路径可以允许写入操作而无需用户权限检查。
更新 UI 组件:增强管理界面,提供多选用户选择器进行细粒度权限分配,支持递归应用到子目录。
pathAllowed.
改进权限逻辑:重构工具栏、右键菜单和编辑器组件中的权限检查,遵循一致的模式:(userCan(permission) || bypass) && pathAllowed。
代码质量改进:在整个代码库中用更简洁的 userCan() 辅助函数替换手动权限索引查找。
Motivation and Context / 背景
The existing permission system only provided coarse-grained control at the user role level, making it difficult to implement scenarios where different users need different
access levels to the same directory, or administrators want to restrict certain paths to specific users only.
现有的权限系统仅提供用户角色级别的粗粒度控制,难以实现不同用户需要对同一目录具有不同访问级别,或管理员希望将某些路径限制为仅特定用户可访问的场景。
Relates to OpenListTeam/OpenList#2145
How Has This Been Tested? / 测试
Manual Testing / 手动测试:
验证操作需要路径级和用户级权限
测试 Meta 管理界面中的多选用户选择器
确认工具栏按钮和右键菜单项根据权限显示/隐藏
验证递归应用到子目录
Test Scenarios / 测试场景:
有 write_content 权限 + write: true → ✓ 可以上传
无 write_content 权限 + write: true → ✗ 无法上传
无权限 + bypass: true + write: true → ✓ 可以上传(旧版行为)
Checklist / 检查清单
我已阅读 https://github.com/OpenListTeam/OpenList/blob/main/CONTRIBUTING.md 文档。
我已使用 go fmt 或 https://prettier.io/ 格式化提交的代码。
我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
Suggested labels / 建议标签: enhancement, frontend, permissions
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。