refactor(auth): 删除无用的 _scope_info 角色

- 删除创建 appAuth 时自动添加的 _scope_info 占位角色
- 删除对 _scope_info 的保留字检查
- 简化代码,避免在数据库中创建无用记录
v3
veypi 1 week ago
parent ba39611f58
commit 51b3bbc89e

@ -109,12 +109,6 @@ func (f *authFactory) New(scope string) Auth {
policies: make(map[string][][2]string), policies: make(map[string][][2]string),
roleInitDone: make(map[string]bool), roleInitDone: make(map[string]bool),
} }
// 设置权限域信息
auth.roleDefs["_scope_info"] = roleDefinition{
code: "_scope_info",
name: scope,
description: scope + " scope",
}
f.apps[scope] = auth f.apps[scope] = auth
return auth return auth
} }
@ -175,9 +169,6 @@ func (a *appAuth) AddRole(roleCode, roleName string, policies ...string) error {
if roleCode == "" || roleName == "" { if roleCode == "" || roleName == "" {
return fmt.Errorf("role code and name cannot be empty") return fmt.Errorf("role code and name cannot be empty")
} }
if roleCode == "_scope_info" {
return fmt.Errorf("reserved role code: _scope_info")
}
// 解析并验证权限格式 // 解析并验证权限格式
parsedPolicies := make([][2]string, 0, len(policies)) parsedPolicies := make([][2]string, 0, len(policies))

Loading…
Cancel
Save