20260908223921
This commit is contained in:
1 parent
8734b43a2a
commit
ead8e66626
60 files changed
+562
-8502
No files matched your search
+18
-21
@@ -273,31 +273,29 @@ create index ix_s_menu_route
|
||||
|
||||
## 8. 权限
|
||||
|
||||
> 权限直接授予用户,不引入角色继承。`s_power.b_id` 是内部主键,`s_power.b_code` 是稳定且全局唯一的业务键;字段授权使用独立的字段访问策略表。
|
||||
> 权限直接授予用户,不引入角色继承。`s_power.b_id` 是权限编码本身(业务键即主键),格式 `类型.对象[.能力]`,例如 `menu.cw_fee`、`module.cw_fee`、`action.cw_fee.audit`;完整规范见《字段权限与用户个性化设计.md》「权限编码规范」。字段授权使用独立的字段访问策略表。
|
||||
|
||||
```sql
|
||||
create table dbo.s_power (
|
||||
b_id bigint not null,
|
||||
b_code varchar(300) not null,
|
||||
b_id varchar(100) not null, -- 权限编码即主键:menu.cw_fee / module.cw_fee / action.cw_fee.audit
|
||||
b_name nvarchar(200) not null,
|
||||
b_i18n varchar(150) null,
|
||||
b_power_type varchar(20) not null, -- menu/page/report/module/action
|
||||
b_resource_id varchar(128) not null,
|
||||
b_owner_type varchar(20) null, -- action owner type
|
||||
b_owner_id varchar(128) null, -- action owner id
|
||||
b_capability varchar(30) not null, -- access/execute/read/create/update/delete/export
|
||||
b_power_type varchar(20) not null, -- page/menu/module/action/report
|
||||
b_owner_type varchar(20) not null, -- 归属对象类型:page/menu/module/report;action 时为所属模块或页面
|
||||
b_owner_id varchar(50) not null, -- 归属对象编码:菜单/模块/页面/报表编码
|
||||
b_capability varchar(30) null, -- action 的操作或动作编码:create/update/delete/export/audit...;入口类为 null
|
||||
b_operation varchar(30) null, -- 兼容列:access/execute,由 b_power_type 派生
|
||||
b_canuse tinyint not null default 1,
|
||||
b_xh int not null default 0,
|
||||
primary key (b_id),
|
||||
unique (b_code)
|
||||
primary key (b_id)
|
||||
);
|
||||
|
||||
create index ix_s_power_resource
|
||||
on dbo.s_power (b_power_type, b_owner_type, b_owner_id, b_resource_id, b_canuse);
|
||||
create index ix_s_power_owner
|
||||
on dbo.s_power (b_power_type, b_owner_type, b_owner_id, b_capability, b_canuse);
|
||||
|
||||
create table dbo.s_user_power (
|
||||
b_user_id varchar(50) not null,
|
||||
b_power_id bigint not null,
|
||||
b_power_id varchar(100) not null, -- s_power.b_id,即权限编码
|
||||
b_canuse tinyint not null default 1,
|
||||
b_updatedatetime datetime2 null,
|
||||
primary key (b_user_id, b_power_id)
|
||||
@@ -345,18 +343,17 @@ create index ix_s_user_data_scope_module
|
||||
|
||||
权限点约定:
|
||||
|
||||
- `menu/access`:菜单或页面入口访问权限;
|
||||
- `module/read|create|update|delete|export`:模块级数据操作权限;
|
||||
- `action/execute`:菜单或页面中的按钮、动作权限;
|
||||
- `page.<页面编码>` / `menu.<菜单编码>` / `report.<报表编码>`:入口访问权限,报表列表中的每个报表可作为一个资源;
|
||||
- `module.<模块编码>`:模块访问(≈ read,能否查看该模块数据);
|
||||
- `action.<模块编码>.<操作或动作>`:数据操作(`create` / `update` / `delete` / `export`)与业务动作(`audit` / `settle` 等)统一为动作权限;
|
||||
- `s_user_field_permission`:字段 `hidden/view/edit` 访问级别,以及独立的查询/导出能力;
|
||||
- `page/access`、`report/access`:独立页面或报表访问权限,报表列表中的每个报表可作为一个资源;
|
||||
- `b_power_type` 和 `b_capability` 是可扩展编码,新增资源类型不新增权限表,但需要补充权限定义和前端/后端校验规则。
|
||||
- 动作业务键必须包含所属资源命名空间,例如 `action.module.cw_fee.audit.execute`,不得使用裸 `action.audit`。
|
||||
- `b_power_type` 和 `b_capability` 是可扩展编码,新增资源类型不新增权限表,但需要补充权限定义和前端/后端校验规则;
|
||||
- 动作必须带所属模块命名空间,例如 `action.cw_fee.audit`,不得使用裸 `action.audit`;**动作归属模块而非菜单**,避免同一个动作在不同菜单下被重复配置。
|
||||
|
||||
权限计算约定:
|
||||
|
||||
- 入口权限默认拒绝:`menu/access`、`page/access`、`report/access` 和 `action/execute` 必须存在有效的 `s_user_power` 授权记录;停用的权限点或授权记录不生效;
|
||||
- 模块操作权限默认放行:`module/read|create|update|delete|export` 没有用户授权记录时视为允许;`s_power` 权限点或用户授权记录存在 `b_canuse = 0` 时视为明确禁用;
|
||||
- 入口权限默认拒绝:`page.*`、`menu.*`、`report.*` 与 `action.*` 必须存在有效的 `s_user_power` 授权记录;停用的权限点或授权记录不生效;
|
||||
- 模块操作 `action.<模块编码>.<操作>` 在没有授权记录时**默认放行还是默认拒绝尚未最终确定**,见《字段权限与用户个性化设计.md》「待确认事项」第 1 条;`s_power` 权限点或用户授权记录存在 `b_canuse = 0` 时视为明确禁用;
|
||||
- 字段没有有效用户策略记录时不增加限制,按 `s_field`、`s_field_view`、`s_field_edit`、`s_field_query` 等模块默认配置执行;有效的 `s_user_field_permission` 只能收紧权限;`hidden` 表示不可见,`view` 表示可见只读,`edit` 表示可见可编辑;
|
||||
- `hidden` 字段不可查询、不可导出;`b_allow_query` / `b_allow_export` 不能突破字段访问级别;
|
||||
- 模块数据操作权限与数据范围同时生效:先判断操作权限,再按 `s_user_data_scope` 限制数据行;数据范围没有配置时视为 `all`;
|
||||
|
||||
Reference in new issue
Block a user