Documentation
¶
Overview ¶
Package authz 承载访问角色(RBAC 最小集)与它在 Go context 里的传递。
## 为什么要有这个包
角色原本只存在 hertz 的 RequestContext 上(`biz/handler/git_sync`)。 但**工具层要判角色**:MCP 端点与 AI 助手都是**进程内直调 core service**, 不过 HTTP 路由 —— 路由上的 WriteGuard/AdminGuard 对它们不生效。
之前写工具只是「因为 MCP 路径不注入会话 scope」才被挡住的 —— 那是偶然,不是设计:一旦有人注入 scope、或新增一个没套守卫的写工具, 天窗立刻成立。
所以角色必须能**跟着 ctx 走到工具层**。而工具包不能反向依赖 biz/handler(会成环),于是角色类型与 ctx 存取都放在这里 —— 它是纯叶子包,谁都能引。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Role ¶
type Role string
Role 访问角色。
func RoleFromContext ¶
RoleFromContext 取 ctx 里的角色;**缺省 readonly(安全侧)**。
缺省安全侧意味着:任何没设角色的调用方都只能做只读的事 —— 新增入口忘了传角色,后果是「不能用」,而不是「什么都能干」。
Click to show internal directories.
Click to hide internal directories.