检查点:保留通知授权开发状态,开始用户分组隔离

This commit is contained in:
xuans committed 2026-09-25 21:19:28 +08:00
1 parent a7eec96bf7
commit 4084bc0682
22 files changed
+1024 -7

No files matched your search

+9
View File
@@ -63,6 +63,10 @@ func Authorize(request Request) error {
func authorizeResource(request Request) error {
switch request.Capability {
case CapabilityNotificationManage:
if !CanManageNotification(request.ActorRole, request.TargetRole, request.OwnResource) {
return deny(CodeTargetRoleDenied)
}
case CapabilityPasswordChangeOwn, CapabilityPluginWriteOwn, CapabilityProfileWriteOwn:
if !request.OwnResource {
return deny(CodeAccessDenied)
@@ -112,6 +116,11 @@ func canManageAccountTarget(actor Role, target Role) bool {
}
}
// 通知授权不改变账号角色;管理员只管理本人和普通用户,不能操作其他管理员。
func CanManageNotification(actor, target Role, own bool) bool {
return target.Valid() && (actor == RoleSuperAdmin || actor == RoleAdmin && (target == RoleUser || own && target == RoleAdmin))
}
func canManagePluginTarget(actor Role, target Role) bool {
if actor == RoleSuperAdmin {
return target.Valid()