From 51b3bbc89e30c87ffa79f152d6f2e286f0a5838f Mon Sep 17 00:00:00 2001 From: veypi Date: Sun, 15 Feb 2026 20:25:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(auth):=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E7=9A=84=20=5Fscope=5Finfo=20=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除创建 appAuth 时自动添加的 _scope_info 占位角色 - 删除对 _scope_info 的保留字检查 - 简化代码,避免在数据库中创建无用记录 --- auth/auth.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 533d806..f6b526b 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -109,12 +109,6 @@ func (f *authFactory) New(scope string) Auth { policies: make(map[string][][2]string), roleInitDone: make(map[string]bool), } - // 设置权限域信息 - auth.roleDefs["_scope_info"] = roleDefinition{ - code: "_scope_info", - name: scope, - description: scope + " scope", - } f.apps[scope] = auth return auth } @@ -175,9 +169,6 @@ func (a *appAuth) AddRole(roleCode, roleName string, policies ...string) error { if roleCode == "" || roleName == "" { 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))