Files
WeiCHEN b627134c62 feat(sysadmin): add system:* permissions and settings audit log
Seed fine-grained console permissions (goose 00065), gate admin
handlers by system:* keys, and persist settings change audits for
all upserts. KB ops and whitelist consumers stay deferred.
2026-09-23 10:09:10 +08:00

37 lines
1.1 KiB
Go
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.
package authz
// 系统管理台细粒度权限(phase-2)。
// 本阶段不改 authz schema / 迁移:系统管理员(role-admin / perm:manage)
// 拥有全部 system:*;非管理员 fail-closed。目录键仅供前端/文档可见。
const (
PermSystemOverview = "system:overview"
PermSystemKBRead = "system:kb:read"
PermSystemFeaturesRead = "system:features:read"
PermSystemSettingsRead = "system:settings:read"
PermSystemSettingsWrite = "system:settings:write"
PermSystemAuditRead = "system:audit:read"
)
// SystemConsolePermissions 返回全部 system:* 键(目录与测试用)。
func SystemConsolePermissions() []string {
return []string{
PermSystemOverview,
PermSystemKBRead,
PermSystemFeaturesRead,
PermSystemSettingsRead,
PermSystemSettingsWrite,
PermSystemAuditRead,
}
}
// IsSystemConsolePermission 判定是否为系统管理台细粒度权限键。
func IsSystemConsolePermission(perm string) bool {
switch perm {
case PermSystemOverview, PermSystemKBRead, PermSystemFeaturesRead,
PermSystemSettingsRead, PermSystemSettingsWrite, PermSystemAuditRead:
return true
default:
return false
}
}