重构: ResScope 改成 ResFlags 位标志,行级过滤与字段脱敏拆成独立开关
ResScope(Off/On/All 三选一)改成 ResFlags 位标志:ResRow/ResRowRelations 管行级权限过滤,ResMask/ResMaskRelations 管字段级脱敏,两个维度可以按位独立组合(*Relations 那两位只保留定义,还没接入判断逻辑)。WithRolesScope 改名 WithPermission(req.ResFlags),dataProcessor 里原来单一的 skipPermission 拆成 skipRowFilter/skipFieldMask 分别控制。
This commit is contained in:
+16
-7
@@ -10,15 +10,24 @@ import (
|
||||
)
|
||||
|
||||
type ResDataType string
|
||||
type ResScope int
|
||||
|
||||
// ResFlags 是一组可以按位组合的权限检查开关,零值表示什么检查都不做。行级过滤
|
||||
// (ResRow)和字段脱敏(ResMask)是两个独立维度,各自的 xxxRelations 位表示"连关联
|
||||
// 资源一起处理",目前只保留位定义,还没接入判断逻辑。
|
||||
type ResFlags int
|
||||
|
||||
const (
|
||||
// 关闭权限过滤
|
||||
ResScopeOff ResScope = iota
|
||||
// 开启权限过滤, 不包括关联资源
|
||||
ResScopeOn
|
||||
// 开启权限过滤, 包括关联资源
|
||||
ResScopeAll
|
||||
// ResRow 行级权限过滤:按角色过滤能看到/操作的行,只处理当前资源自己
|
||||
ResRow ResFlags = 1 << iota
|
||||
// ResRowRelations 行级权限过滤扩展到关联资源(依附于 ResRow,单独设置无效果,尚未实现)
|
||||
ResRowRelations
|
||||
// ResMask 字段级脱敏:按 ResField.GetRoles() 脱敏无权限查看/写入的字段,只处理当前资源自己
|
||||
ResMask
|
||||
// ResMaskRelations 字段级脱敏扩展到关联资源(依附于 ResMask,单独设置无效果,尚未实现)
|
||||
ResMaskRelations
|
||||
|
||||
// ResAll 常用组合:行级过滤 + 字段脱敏都开启(不含关联资源)
|
||||
ResAll = ResRow | ResMask
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user