Apache Casbin Gateway
1. 开始使用

1.2 安装

一条命令。不需要数据库,不需要Go,不需要Node,也不需要先写配置文件。

Linux和macOS

curl -fsSL https://raw.githubusercontent.com/apache/casbin-gateway/master/scripts/install.sh | bash

Windows

在PowerShell里:

irm https://raw.githubusercontent.com/apache/casbin-gateway/master/scripts/install.ps1 | iex

安装脚本做了什么

  1. 下载适合这台机器的构建,解包到~/.local/share/casbin-gateway(Windows上是%LOCALAPPDATA%\casbin-gateway)。
  2. 把casbin-gateway命令放进PATH。
  3. 启动它,并设置成登录时自动启动。
  4. 按平台在桌面和开始菜单、~/Applications或应用菜单里加一个Casbin Gateway入口。

装完终端立刻还给你。手动解包的压缩包,在启动器第一次运行时也会补上同样的入口。

在已经装过的机器上再运行一次这条命令,就是升级:正在运行的Gateway会先被停掉,这样之后提供服务的就是新版本,放好之后再把它重新启动。

变量作用
INSTALL_DIR装到默认目录以外的地方
NO_START=1只安装,不启动。被这次安装停掉的Gateway仍会重新启动
NO_AUTOSTART=1只安装,不设置开机自启动

第一次启动

Gateway会打开自己的窗口。没有登录页:它只服务本机,看到本机请求就直接把本地管理员登录上。

关掉那个窗口,Gateway会留在托盘图标后面继续跑。托盘菜单也是重新打开窗口、开关Start at Login(和设置→开机自启动是同一个开关)、以及真正退出的地方。

如果你更想用浏览器,或者这台机器根本没有桌面环境,所有东西都在**http://localhost:17000**;`casbin-gateway start`会只跑服务端,没有窗口也没有托盘。

自动登录背后的账号是admin / 123。只有当你把Gateway开放给网络时它才有意义,见5.2 安全与对外提供服务。

文件都在哪

Gateway所有东西都写在自己的安装目录下:

路径内容
data/casbin-gateway.dbSQLite数据库:供应商、设置、记录、权限
data/Agent的改写状态
logs/casbin-gateway.out后台运行时的控制台输出
tmp/临时文件

装好的casbin-gateway命令是个包装器,永远在安装目录里启动Gateway,所以在哪个目录执行都一样。直接从别的地方运行那个可执行文件,会在那里得到第二个空的安装。

确认它起来了

Gateway启动时会把自己实际在做什么打出来,这样不用去翻配置文件也能确认结果:

+---------------------------------------------------------------------+
| Casbin Gateway                                                      |
+---------------------------------------------------------------------+
| Management UI | http://localhost:17000 (this machine only)          |
| Settings      | Settings page, seeded from conf/app.conf            |
| Web UI files  | web/build                                           |
| Database      | sqlite, file "./data/casbin-gateway.db" (connected) |
| Sign-in       | built-in user table, Casdoor is not configured      |
| Relay auth    | this machine only, no token needed                  |
+---------------------------------------------------------------------+

之后想再确认,用casbin-gateway status。

如果17000端口上还有一个旧的Gateway,会先把它停掉,所以重启不会卡在端口上。端口被别的程序占着时,Gateway会说出占用它的进程然后退出,而不是抢端口,也不是半配置地起来。

从源码构建

需要Go 1.25+以及带Yarn的Node.js,命令见README。

注意一键安装分发的是nightly构建:master每次推送都会重新构建,发布为nightly预发布版。它的存在是为了让人不装Go和Node工具链也能试用;其他场景应该从源码发布版构建。

下一节:1.3 界面导览。

在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.

本页内容