跳到主内容

Configuration reference

Casdoor reads its settings from one file, conf/app.conf. You can override every option with an environment variable. This page lists all options.

For a minimal setup, set only driverName, dataSourceName, and dbName. See Configure the database.

Backend options​

The options appear in the order of conf/app.conf. Restart Casdoor after you change an option.

OptionDefault描述
appnamecasdoorApplication name. Not used at the moment
httpport8000后端应用程序监听的端口
runmodedev运行模式:dev 或 prod
copyrequestbodytrue是否复制请求体以供后续使用
driverNamemysql数据库驱动程序(例如:mysql、postgres、sqlite)。 See Configure the database
dataSourceNameroot:123456@tcp(localhost:3306)/数据库连接字符串。 See Configure the database
dbNamecasdoorCasdoor 使用的数据库名称
tableNamePrefix(empty)使用适配器时表名的前缀
showSqlfalse当日志级别大于INFO时,在日志中显示 SQL 语句
redisEndpoint(empty)用于会话存储的Redis端点(例如:localhost:6379)。如果为空,会话将存储在本地./tmp中。密码方式:host:port,db,password
sessionCookieLifeTime(empty)会话 Cookie 的有效期(秒)。为空或不大于 0 时默认 30 天(2592000);设置大于 0 的值即可覆盖。
defaultStorageProvider(empty)文件上传(例如头像)的默认存储提供程序名称。请参阅 storage
isCloudIntranetfalse提供者端点是否使用内网地址
authState"casdoor"Authorization application name that Casdoor checks during sign-in
socks5Proxy"127.0.0.1:10808"OAuth提供商(Google、GitHub等)的SOCKS5代理地址可能被阻止
verificationCodeTimeout10验证码有效期,单位:分钟
initScore0分配给新用户的初始分数(由Casnode使用,而非Casdoor)
logPostOnlytrue是否只记录 POST 请求
isUsernameLoweredfalse是否将用户名转换为小写
origin(empty)后端源URL(例如:https://door.casdoor.com)
originFrontend(empty)若前后端URL不同则以前端URL为准
trustedProxies(empty)Comma-separated IPs or CIDR ranges of reverse proxies whose X-Forwarded-For and X-Real-IP headers are trusted for the client IP (* trusts any). When empty, loopback and private addresses are trusted
staticBaseUrl"https://cdn.casbin.org"数据库初始化期间使用静态资源的 CDN URL
frontendCdnUrl(empty)Serve the frontend's JavaScript and CSS from a CDN, e.g. https://cdn.jsdelivr.net/npm/{name}@{version}. Only applies to a frontend installed from the casdoor-web npm package; files that fail to load from the CDN are loaded from Casdoor
isDemoModefalse启用演示模式限制
batchSize100批量操作的批量大小
showGithubCornerfalse在界面上显示 GitHub 角操作区
forceLanguage""强制界面使用指定语言(例如 "zh"、"en")。覆盖用户的浏览器语言。空值表示不进行覆盖。
defaultLanguage"en"当未设置浏览器偏好或强制覆盖时的默认UI语言
defaultApplication"app-built-in"Name of the application to redirect to after sign-in when no specific application is requested
maxItemsForFlatMenu7平铺(非分组)侧栏菜单中最多显示的项目数。当计数超过此值时,菜单将切换为树状/分组视图
enableErrorMaskfalse是否屏蔽详细错误消息
enableErrorMask2falseReplace every API error message with a generic one, so that responses don't reveal why a request failed
enableGziptrue当客户端支持时,接受并以gzip编码响应
inactiveTimeoutMinutes(empty)Automatic sign-out timeout in minutes. 为空或≤0表示无超时
ldapServerPort389LDAP服务器端口
ldapsCertId""LDAPS 连接的证书 ID
ldapsServerPort636LDAPS(LDAP over SSL)服务器端口
radiusServerPort1812RADIUS服务器端口
radiusDefaultOrganization"built-in"RADIUS认证的默认组织
radiusSecret"secret"RADIUS认证共享密钥
gatewayHttpPort80HTTP port of the reverse-proxy gateway for Sites. The gateway only starts when at least one site exists
gatewayHttpsPort443HTTPS port of the reverse-proxy gateway for Sites
acmeEmail(empty)Email of the ACME (Let's Encrypt) account used to issue certificates for Sites
acmePrivateKey(empty)Private key (PEM) of that ACME account
quota{"organization": -1, "user": -1, "application": -1, "provider": -1}资源配额(-1 表示无限制)
logConfig{"adapter":"file", "filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}日志配置 (适配器、文件路径、旋转、权限)
initDataNewOnlyfalseOnly add the objects of the init data file that don't exist yet, existing ones are left as they are
initDataMergefalseUpdate the existing objects with only the fields set in the init data file, instead of deleting and re-creating them
initDataFile"./init_data.json"Path to the data initialization file, JSON or YAML (.yaml/.yml). See Data initialization
initDataWatchInterval0Seconds between the checks of the init data file for changes, a changed file is applied again without a restart. 0 applies it only at startup
frontendBaseDir"../cc_0"前端文件的基础目录 (仅用于开发)

Override options with environment variables​

An environment variable with the same name as an option in app.conf overrides the value in the file. The name must match the option name exactly, including case. Some Beego options, such as httpport and appname, work the same way.

Set a variable for one run:

appname=casbin go run main.go

Or export it in the shell before you start Casdoor:

export httpport=9000
./casdoor

In Docker, pass the options with -e. See Try with Docker.

Options that affect the admin console​

The frontend reads the following options from the backend at runtime. Change them in app.conf or with environment variables and restart the backend. You don't need to rebuild the frontend.

OptionEffect on the admin console
defaultApplicationApplication whose sign-in page appears when the request names no application
defaultLanguageLanguage used when the browser doesn't ask for a supported one
forceLanguageLanguage used for every user, regardless of the browser language
isDemoModeRestricts what the console allows, for public demo sites
maxItemsForFlatMenuNumber of top menu items above which the menu is grouped
showGithubCornerShows the GitHub corner ribbon
staticBaseUrlBase URL of static images such as logos and avatars

Compile-time frontend settings​

The compile-time defaults of the options above, the default theme (ThemeDefault), and an optional custom footer (CustomFooter) are in web/src/Conf.ts. After you change that file, rebuild the frontend:

cd web
yarn build

To set a theme for one organization or one application, use the admin console instead. See Customize the theme.

See also​