Apache Casbin Gateway
4. 管控

4.1 权限

权限页一侧是本机的每个Agent,另一侧是你选中的那个能做什么。Agent自己的页面上有同一张卡片。

可以给一个Agent比它自带的更少的权限,而不用改它自己的配置。

权限

工具

四十来个开关,分六组:

分组覆盖
终端执行命令、读取正在执行的命令的输出、终止它——三个独立开关
读取项目读文件、列目录、搜索
修改项目写入、编辑、删除
互联网抓取网页、联网搜索
规划与委派任务规划、子Agent
MCP该Agent装的每个MCP服务器一个开关
  • 分组标题上的开关一次设置整组;展开之后可以细到你想要的程度。
  • 关掉的工具会在请求离开这台机器之前被摘掉,所以模型压根看不到它,Agent也就没机会调用。
  • 每个Agent给工具起的名字都不一样,Bash、shell和run_shell_command都是同一个开关。
  • 每一组末尾有一个兜底项,管Gateway从没见过的工具——这才是把一组彻底关死,而不是只关掉设置那天恰好列出来的那几个。

模型

任意模型、只允许你选的那些、或者除了这些以外都行。名字末尾可以带*,所以claude-opus-*能覆盖一整个系列。

供应商

这个Agent的请求可以发往哪些供应商。

被拒绝时长什么样

请求里要的东西被关掉时,返回的是Agent所说那套API里的permission_error,所以它读起来是一次拒绝,而不是网关坏了。

规则在哪里生效

两个执行点,页面会说明某个Agent属于哪一种:

Agent工具模型与供应商
流量走Gateway(3.2)从转发的请求里摘掉每个请求都校验
不走Gateway,但开了监控(2.3)由Gateway装的钩子在工具执行前拒掉不生效——没有请求经过Gateway可管
两者都不是——

底层:Casbin

这些开关会编译成一份Casbin策略,每个转发的请求由enforcer裁决,而不是靠手写的if。

高级会展示它们编译出来的model.conf和policy.csv,也接受你自己写的策略行:

p, claude-code, model:claude-opus-*, use, deny
p, claude-code, model:*, use, allow
p, claude-code, tool:shell/run, use, deny
p, claude-code, tool:mcp/github, use, allow
p, claude-code, tool:mcp/*, use, deny
p, claude-code, tool:*, use, allow

第一条匹配的规则说了算,这正是"一个例外挡在后面那条规则前面"的写法:收掉所有MCP服务器,只留下那一个。

你自己写的行,会在开关生成的那些行之前被检查。

下一节:4.2 LLM记录。

在GitHub上编辑
Apache Incubator

Apache Casbin (Incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Copyright © 2026 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.

Apache, Apache Casbin, the names of Apache projects, and the feather logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. All other marks mentioned may be trademarks or registered trademarks of their respective owners.

本页内容