Перейти до основного вмісту

Довідка з конфігурації

Casdoor читає свої налаштування з одного файлу, conf/app.conf. Ви можете перевизначити кожну опцію за допомогою змінної середовища. Ця сторінка містить перелік усіх опцій.

Для мінімальної конфігурації встановіть лише driverName, dataSourceName та dbName. Див. Налаштування бази даних.

Опції бекенду​

Опції наведені в порядку їх розташування у conf/app.conf. Перезавантажте Casdoor після зміни будь-якої опції.

OptionDefaultОпис
appnameкасдорApplication name. Not used at the moment
httpport8000Port that the backend application listens on
runmodedevRunning mode: dev or prod
copyrequestbodyтакWhether to copy request body for later use
driverNamemysqlDatabase driver (e.g., mysql, postgres, sqlite). See Configure the database
dataSourceNameroot:123456@tcp(localhost:3306)/Database connection string. See Configure the database
dbNameкасдорDatabase name used by Casdoor
tableNamePrefix(empty)Prefix for table names when using an adapter
showSqlніShow SQL statements in logger when log level is greater than INFO
redisEndpoint(empty)Redis server for the session store and the OAuth device authorization store, in the format host:port[,poolSize[,password[,db]]], for example localhost:6379,100,<redis-password>,2. poolSize defaults to 1000 and db to 0. List several addresses separated by ; in the first field to use Redis Cluster, for example 10.0.0.1:6379;10.0.0.2:6379,100,<redis-password>; db isn't used in cluster mode. If empty, sessions are stored in files in ./tmp and device authorizations in memory. If Redis can't be reached at startup, device authorizations fall back to memory
sessionCookieLifeTime(empty)Session cookie lifetime in seconds. Defaults to 30 days (2592000) when empty or not greater than 0; set a value greater than 0 to override it.
defaultStorageProvider(empty)Default storage provider name for file uploads (e.g., avatars). See storage
isCloudIntranetніWhether provider endpoints use intranet addresses
authState"casdoor"Authorization application name that Casdoor checks during sign-in
socks5Proxy"127.0.0.1:10808"SOCKS5 proxy for OAuth providers (Google, GitHub, etc.) that may be blocked. Use host:port, or socks5://<user>:<password>@host:port for a proxy that requires authentication. If the proxy can't be reached at startup or the URL is invalid, Casdoor connects directly. Email providers with Enable proxy need the plain host:port form, without credentials
verificationCodeTimeout10Verification code expiration time in minutes
initScore0Initial score assigned to new users (used by Casnode, not Casdoor)
logPostOnlyтакWhether to record only non-GET requests. logout and sso-logout are recorded for GET requests too, for example OpenID Connect RP-initiated logout through GET /api/logout, so that their records and webhooks aren't lost
isUsernameLoweredніWhether to convert usernames to lowercase
origin(empty)Backend origin URL (e.g., https://door.casdoor.com)
originFrontend(empty)Frontend origin URL if different from backend
basePath(empty)Path that Casdoor is served under behind a reverse proxy, for example /casdoor. Empty serves Casdoor at the root. See Serve Casdoor under a path
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 for static assets used during database initialization
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
formCssAllowedUrls(empty)Comma-separated URL prefixes from which organization admins may load images, fonts, and other files in the custom HTML and CSS of applications, in addition to this Casdoor's origin, the domains of global storage providers, and built-in font and CDN hosts. An entry without a scheme gets https://. See Customize the look of the sign-in page
isDemoModeніMake the site a read-only public demo: most write requests are refused (sign-in, sign-up, sign-out, verification codes, and users editing their own profile still work), withSecret=1 is refused, and built-in/admin is created with the password 123 when initAdminPassword is empty. A dbName of casdoor_demo applies the same rules except the read-only one, and also refuses changes to the Host, Endpoint, or Type of a provider
batchSize100Batch size for bulk operations
showGithubCornerніShow the GitHub corner ribbon on the UI
forceLanguage""Language of the UI (e.g. "zh", "en") for visitors who haven't picked a language in this browser. Overrides the browser language, but not a language that the user picked. Empty means no override. See How Casdoor picks the language
defaultLanguage"en"Default UI language when no browser preference or force override is set
defaultApplication"app-built-in"Name of the application to redirect to after sign-in when no specific application is requested
maxItemsForFlatMenu7Maximum number of items to show in a flat (non-grouped) sidebar menu. When the count exceeds this, the menu switches to a tree/grouped view
enableErrorMaskніWhether to mask detailed error messages
enableErrorMask2ніReplace every API error message with a generic one, so that responses don't reveal why a request failed
enableGzipтакAccept and respond with gzip encoding when client supports it
inactiveTimeoutMinutes(empty)Automatic sign-out timeout in minutes. Empty or ≤0 means no timeout
ldapServerPort389Port for LDAP server
ldapsCertId""Certificate ID for LDAPS connections
ldapsServerPort636Port for LDAPS (LDAP over SSL) server
radiusServerPort1812Port for RADIUS server
radiusDefaultOrganization"built-in"Default organization for RADIUS authentication
radiusSecret"secret"Спільний секрет для автентифікації та обліку RADIUS. Це один секрет для всіх клієнтів RADIUS: Casdoor не підтримує окремі секрети для кожного клієнта
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
квота{"organization": -1, "user": -1, "application": -1, "provider": -1}Resource quotas (-1 means unlimited)
logConfig{"adapter":"file", "filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}Logging configuration (adapter, file path, rotation, permissions)
initAdminPassword(empty)Password of built-in/admin when Casdoor creates it on an empty database. Existing databases aren't changed. If empty, the first visitor sets the password on the Welcome to Casdoor page, except in demo mode (see isDemoMode). See Sign in to the admin console
initDataNewOnlyніOnly 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
disableVersionCheckfalseНе перевіряти GitHub на наявність останнього релізу Casdoor на сторінці System Info, наприклад, для автономного або внутрішньомережевого розгортання. Див. Оновлення Casdoor
disableUpgradefalseПриховати кнопку оновлення одним кліком бінарних файлів релізів на сторінці System Info та відхиляти запити API оновлення. Див. Оновлення Casdoor
frontendBaseDir"../cc_0"Base directory for frontend files (only for development)

Перевизначення опцій через змінні середовища​

Змінна середовища з тією ж назвою, що й опція в app.conf, перевизначає значення у файлі. Назва повинна точно відповідати назві опції, включаючи регістр. Деякі опції Beego, такі як httpport та appname, працюють аналогічним чином.

Встановіть змінну для одного запуску:

appname=casbin go run main.go

Або експортуйте її в оболонці перед запуском Casdoor:

export httpport=9000
./casdoor

У Docker передавайте опції за допомогою -e. Див. Запуск у Docker.

Читання параметрів із файлів​

Щоб уникнути розміщення секретів, таких як dataSourceName або redisEndpoint, у змінних середовища, покладіть значення у файл і встановіть <option>_FILE на шлях до цього файлу. Це працює з секретами Docker та Kubernetes, які монтовуються як файли:

docker run -e driverName=postgres \
-e dataSourceName_FILE=/run/secrets/casdoor_dsn \
casbin/casdoor
  • Це стосується будь-якого параметра на цій сторінці.
  • Змінна середовища, названа так само, як сам параметр, має пріоритет над <option>_FILE.
  • Casdoor видаляє пробіли та символи нового рядка в кінці файлу, тому файл, створений командою echo, працюватиме коректно.
  • Якщо файл неможливо прочитати, Casdoor зупиниться з помилкою, яка вказує назву параметра.

Опції, що впливають на консоль адміністратора​

Фронтенд зчитує наступні опції з бекенду під час виконання. Змініть їх у app.conf або через змінні середовища та перезавантажте бекенд. Перебудова фронтенду не потрібна.

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 instead of the browser language, until the user picks another one
isDemoModeMakes the console read-only, for public demo sites. Also shows the Marketplace themes in turn on the sign-in pages and lets visitors switch between them, as does a dbName of casdoor_demo
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

Налаштування фронтенду часу компіляції​

Стандартні значення наведених вище опцій часу компіляції, тема за замовчуванням (ThemeDefault) та необов'язковий користувацький футер (CustomFooter) знаходяться у файлі web/src/Conf.ts. Після зміни цього файлу перебудуйте фронтенд:

cd web
yarn build

Щоб встановити тему для однієї організації або одного додатка, скористайтеся консоллю адміністратора. Див. Налаштування теми.

Див. також​