Server Installation
Requirements
OS
All OSes (Linux, Windows and macOS) are supported.
Environment
info
We strongly suggest you use Yarn 1.x to run & build Casdoor frontend, using NPM might cause UI styling issues, see more details at: casdoor#294
Database
Casdoor uses XORM to talk to the database. Based on Xorm Drivers Support, The current supported databases are:
MySQL
MariaDB
PostgreSQL
SQL Server
Oracle
SQLite 3
TiDB
Download
The source code of Casdoor is hosted at GitHub: https://github.com/casdoor/casdoor . Both the Go backend code and React frontend code are inside the single repository.
Name | Description | Language | Source code |
---|---|---|---|
Frontend | Web frontend UI for Casdoor | JavaScript + React | https://github.com/casdoor/casdoor/tree/master/web |
Backend | RESTful API backend for Casdoor | Golang + Beego + XORM | https://github.com/casdoor/casdoor |
Casdoor supports Go Modules
. To download the code, you can just simply clone the code via git:
cd path/to/folder
git clone https://github.com/casdoor/casdoor
Configuration
Casdoor can be configured via a single file: conf/app.conf, the content of which by default is:
appname = casdoor
httpport = 8000
runmode = dev
SessionOn = true
copyrequestbody = true
driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor
redisEndpoint =
defaultStorageProvider =
isCloudIntranet = false
authState = "casdoor"
httpProxy = "127.0.0.1:10808"
verificationCodeTimeout = 10
initScore = 2000
logPostOnly = true
origin = "https://door.casbin.com"
appname
is the application name, which currently has no practical usehttpport
is the port that your back-end application is listening onrunmode
isdev
orprod
SessionOn
decides whether to enable session,used by default.driverName
,dataSourceName
anddbName
are introduced before, please see Config.useProxy
set the proxy port, because we have google-related services, which will be restricted by the network in some areasverificationCodeTimeout
set the expiration time of the verification code. After the expiration, the user needs to obtain it again
Despite all the configurable fields, as a beginner, you only need to modify two items: driverName
and dataSourceName
based on your database. This database will be used by Casdoor to store all data, including users, organizations, applications and so on.
Setup database (MySQL):
Casdoor will store its users, nodes and topics information in a MySQL database named:
casdoor
, will create it if not existed. The DB connection string can be specified at: https://github.com/casdoor/casdoor/blob/master/conf/app.confdriverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casdoor
Setup database (Postgres):
Since we must choose a database when opening Postgres with xorm, you should prepare a database manually before running Casdoor.
Let’s assume that you have already prepared a database called
casdoor
, then you should specifyapp.conf
like this:driverName = postgres
dataSourceName = "user=postgres password=xxx sslmode=disable dbname="
dbName = casdoor
Please notice: You can add Postgres parameters in
dataSourceName
, but please make sure thatdataSourceName
ends withdbname=
. Or database adapter may crash when you launch Casdoor.Other database…
Run
There are currently two methods to start, you can choose one according to your own situation.
Development mode
Backend
Casdoor’s Go backend runs at port 8000 by default. You can start the Go backend with the following command:
go run main.go
After the server is successfully running, we can start the frontend part.
Frontend
Casdoor’s frontend is a very classic Create-React-App (CRA) project. It runs at port 7001
by default. Use the following commands to run the frontend:
cd web
yarn install
yarn start
Visit: http://localhost:7001 in your browser. Log into Casdoor dashboard with the default global admin account: built-in/admin
admin
123
Production mode
Backend
Build Casdoor Go backend code into executable and start it.
For Linux:
go build
./casdoor
For Windows:
go build
casdoor.exe
Frontend
Build Casdoor frontend code into static resources (.html, .js, .css files):
cd web
yarn install
yarn build
Visit: http://localhost:8000 in your browser. Log into Casdoor dashboard with the default global admin account: built-in/admin
admin
123
tip
To use another port, please edit conf/app.conf
and modify httpport
, then restart the Go backend.
casdoor port details
In dev environment, the frontend is run by yarn run
in port 7001, so if you want to go to Casdoor login page, you need set Casdoor link as http://localhost:7001.
In prod environment, the frontend files is first built by yarn build
and served in port 8000, so if you want to go to Casdoor login page, you need to set Casdoor link as http://SERVER\_IP:8000 (If you are using reverse proxy, you need to set the link as your domain).
Take our official forum Casnode as an example:
Casnode uses Casdoor to handle authentication.
When we are testing Casnode in dev environment, we set the serverUrl
as http://localhost:7001, so when we test signin and signup functionality using Casdoor, it will go to localhost 7001 which is the Casdoor port.
And when we put Casnode to prod environment, we set the serverUrl
as https://door.casbin.com, so users can signin or signup using Casdoor.