forked from casdoor/casdoor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve code specification (casdoor#231)
- Loading branch information
Showing
36 changed files
with
209 additions
and
164 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,146 +1,131 @@ | ||
Casdoor | ||
==== | ||
|
||
[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/casdoor)](https://goreportcard.com/report/github.com/casbin/casdoor) <img src="https://img.shields.io/github/license/casbin/casdoor?style=flat-square" alt="license"> [![GitHub issues](https://img.shields.io/github/issues/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/issues) [![GitHub stars](https://img.shields.io/github/stars/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/stargazers) [![GitHub forks](https://img.shields.io/github/forks/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/network) | ||
|
||
Casdoor is a UI-first centralized authentication / Single-Sign-On (SSO) platform based on OAuth 2.0 / OIDC. | ||
|
||
## Online demo | ||
|
||
### Casdoor | ||
Deployed site: https://door.casbin.com/ | ||
|
||
## Quick Start | ||
|
||
Run your own casdoor program in a few minutes:smiley: | ||
|
||
### Download | ||
|
||
There are two methods, get code via go subcommand `get`: | ||
|
||
```shell | ||
go get github.com/casbin/casdoor | ||
``` | ||
|
||
or `git`: | ||
|
||
Casdoor is the authentication server. It serves both the web UI and the login requests from the application users. | ||
```bash | ||
git clone https://github.com/casbin/casdoor | ||
``` | ||
|
||
- Deployed site: https://door.casbin.com/ | ||
- Source code: https://github.com/casbin/casdoor (this repo) | ||
Finally, change directory: | ||
|
||
Global admin login: | ||
```bash | ||
cd casdoor/ | ||
``` | ||
|
||
- Username: `admin` | ||
- Password: `123` | ||
We provide two start up methods for all kinds of users. | ||
|
||
### Web application | ||
### Manual | ||
|
||
Casbin-OA is one of our applications that use Casdoor as authentication. | ||
#### Simple configuration | ||
|
||
- Deployed site: https://oa.casbin.com/ | ||
- Source code: https://github.com/casbin/casbin-oa | ||
Edit `conf/app.conf`, modify `dataSourceName` to correct database info, which follows this format: | ||
|
||
## Architecture | ||
```bash | ||
username:password@tcp(database_ip:database_port)/ | ||
``` | ||
|
||
Casdoor contains 2 parts: | ||
#### Run | ||
|
||
Name | Description | Language | Source code | ||
----|------|----|---- | ||
Frontend | Web frontend UI for Casdoor | Javascript + React | https://github.com/casbin/casdoor/tree/master/web | ||
Backend | RESTful API backend for Casdoor | Golang + Beego + MySQL | https://github.com/casbin/casdoor | ||
Casdoor provides two run modes, the difference is binary size and user prompt. | ||
|
||
## Installation | ||
##### Dev Mode | ||
|
||
- Get code via `go get`: | ||
Edit `conf/app.conf`, set `runmode=dev`. Firstly build front-end files: | ||
|
||
```shell | ||
go get github.com/casbin/casdoor | ||
``` | ||
```bash | ||
cd web/ && npm install && npm run start | ||
``` | ||
|
||
or `git clone`: | ||
Then build back-end binary file, change directory to root(Relative to casdoor): | ||
|
||
```shell | ||
git clone https://github.com/casbin/casdoor | ||
``` | ||
```bash | ||
go run main.go | ||
``` | ||
|
||
## Run through Docker | ||
- Install Docker and Docker-compose,you see [docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/) | ||
- vi casdoor/conf/app.conf | ||
- Modify dataSourceName = root:123@tcp(localhost:3306)/ to dataSourceName = root:123@tcp(db:3306)/ | ||
- Execute the following command | ||
```shell | ||
docker-compose up | ||
``` | ||
- Open browser: | ||
That's it! Try to visit http://127.0.0.1:7001/. :small_airplane: | ||
|
||
http://localhost:8000/ | ||
##### Prod Mode | ||
|
||
## Run (Dev Environment) | ||
Edit `conf/app.conf`, set `runmode=prod`. Firstly build front-end files: | ||
|
||
- Run backend (in port 8000): | ||
```bash | ||
cd web/ && npm install && npm run build | ||
``` | ||
|
||
```shell | ||
go run main.go | ||
``` | ||
Then build back-end binary file, change directory to root(Relative to casdoor): | ||
|
||
- Run frontend (in the same machine's port 7001): | ||
```bash | ||
go build main.go && sudo ./main | ||
``` | ||
|
||
```shell | ||
cd web | ||
## npm | ||
npm install | ||
npm run start | ||
## yarn | ||
yarn install | ||
yarn run start | ||
``` | ||
> Notice, you should visit back-end port, default 8000. Now try to visit http://127.0.0.1:8000/ | ||
- Open browser: | ||
### Docker | ||
|
||
http://localhost:7001/ | ||
This method requires [docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/) to be installed first. | ||
|
||
## Run (Production Environment) | ||
#### Simple configuration | ||
|
||
- build static pages: | ||
Edit `conf/app.conf`, modify `dataSourceName` to the fixed content: | ||
|
||
``` | ||
cd web | ||
## npm | ||
npm run build | ||
## yarn | ||
yarn run build | ||
## back to casdoor directory | ||
cd .. | ||
``` | ||
```bash | ||
dataSourceName = root:123@tcp(db:3306)/ | ||
``` | ||
|
||
- build and run go code: | ||
> If you need to modify `conf/app.conf`, you need to re-run `docker-compose up`. | ||
``` | ||
go build | ||
./casdoor | ||
``` | ||
#### Run | ||
|
||
Now, Casdoor is running on port 8000. You can access Casdoor pages directly in your browser, or you can setup a reverse proxy to hold your domain name, SSL, etc. | ||
Just execute: | ||
|
||
## Config | ||
```bash | ||
docker-compose up | ||
``` | ||
|
||
- Setup database (MySQL): | ||
That's | ||
|
||
Casdoor will store its users, nodes and topics informations in a MySQL database named: `casdoor`, will create it if not existed. The DB connection string can be specified at: https://github.com/casbin/casdoor/blob/master/conf/app.conf | ||
## Detailed documentation | ||
|
||
```ini | ||
db = mysql | ||
dataSourceName = root:123@tcp(localhost:3306)/ | ||
dbName = casdoor | ||
``` | ||
We also provide a complete [document](https://casdoor.org/) as a reference. | ||
|
||
- Setup database (Postgres): | ||
## Other examples | ||
|
||
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 specify `app.conf` like this: | ||
These all use casdoor as a centralized authentication platform. | ||
|
||
``` ini | ||
db = postgres | ||
dataSourceName = "user=postgres password=xxx sslmode=disable dbname=" | ||
dbName = casdoor | ||
``` | ||
- [Casnode](https://github.com/casbin/casnode): Next-generation forum software based on React + Golang. | ||
- [Casbin-OA](https://github.com/casbin/casbin-oa): A full-featured OA(Office Assistant) system. | ||
- ...... | ||
|
||
**Please notice:** You can add Postgres parameters in `dataSourceName`, but please make sure that `dataSourceName` ends with `dbname=`. Or database adapter may crash when you launch Casdoor. | ||
## Contribute | ||
|
||
Casdoor uses XORM to connect to DB, so all DBs supported by XORM can also be used. | ||
For casdoor, if you have any questions, you can give Issues, and you can also directly Pull Requests(but we recommend give issues first to communicate with the community). | ||
|
||
- Github corner | ||
In addition to contributing codes to casdoor, uou can also contribute to the [internationalization of casdoor](https://crowdin.com/project/casdoor-web) by translating for casdoor in the language you are good at. | ||
|
||
We added a Github icon in the upper right corner, linking to your Github repository address. | ||
You could set `ShowGithubCorner` to hidden it. | ||
Both are welcome! :kissing_smiling_eyes: | ||
|
||
Configuration (`web/src/commo/Conf.js`): | ||
## License | ||
|
||
```javascript | ||
export const ShowGithubCorner = true | ||
[Apache-2.0](https://github.com/casbin/casdoor/blob/master/LICENSE) | ||
|
||
export const GithubRepo = "https://github.com/casbin/casdoor" //your github repository | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.