liuyun 1790fb30a8 chore(openspec): archive close-phase-0, sync backend specs to main
- 归档 close-phase-0(RBAC 权限 + 审计/登录日志 + seed 收口)
- 新增主 spec:backend/auth、backend/res、backend/audit、backend/login
- 追踪 sysmgr-nest passwordHash 泄漏修复

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-10 23:23:56 +08:00

33 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Resource Authorization Specification
## Purpose
定义资源表作为 RBAC 授权锚点的运行时语义:权限码即资源 code,采用细粒度 domain:action 命名。
## Requirements
### Requirement: 权限码即资源 code
系统 SHALL 以资源表的 `code` 作为接口与按钮的权限标识;`@RequirePermissions` 的参数 SHALL 为该 code 字符串。
#### Scenario: 接口声明权限码
- **WHEN** 接口声明 `@RequirePermissions('user:create')`
- **THEN** 系统校验当前用户权限集是否包含字符串 `user:create`
### Requirement: 权限码格式
权限码 SHALL 采用细粒度 `domain:action` 格式(domain 为域,action 为动作,如 `user:list`、`user:create`、`role:assign`)。
#### Scenario: 细粒度权限码
- **WHEN** 为「创建用户」接口登记权限码
- **THEN** 该接口资源 code 为 `user:create`
### Requirement: 权限码聚合来源
用户权限集 SHALL 由其全部角色的 role_resource 关联(role_code + resource_code),取其中 `type ∈ {button, api}` 的 resource.code 并集聚合得到。
#### Scenario: 多角色权限并集
- **WHEN** 用户拥有两个角色,各自关联了部分资源
- **THEN** 该用户权限集为两角色资源 code 的并集
#### Scenario: 菜单不计入接口权限集
- **WHEN** 用户角色关联了 `type=menu` 的资源
- **THEN** 该 menu 的 code 不进入接口权限集(菜单用于导航渲染,不用于接口鉴权)