|
|
|
@ -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))
|
|
|
|
|