Skip to content

Commit

Permalink
docs: add installation.md (#8)
Browse files Browse the repository at this point in the history
* docs: add installation.md

* docs: add installation.md

* docs: add installation.md

* docs: add installation.md
  • Loading branch information
leo220yuyaodog authored Jan 10, 2024
1 parent 882ac5e commit 3c9e6b6
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
142 changes: 142 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
title: Server Installation
description: Install and configure Casvisor server.
keywords: [Casvisor server, installation, configuration]
authors: [leo220yuyaodog]
---

## Prerequisite

Casvisor server uses Casdoor as the authentication and authorization system. So you need to install Casdoor first. If
you haven't installed Casdoor, please refer to [Casdoor Installation](https://casdoor.org/docs/basic/server-installation).

### Casdoor configuration

You have installed Casdoor, now you need to do some necessary configuration in Casdoor in order to use Casvisor.

#### Create an organization

First, you need to create an organization (Except for the `build-in`) in Casdoor. The organization page is at **User Management -> Organizations**.
And you can create an organization by clicking the `add` button.

![create organization](/img/installtion_organization.png)

#### Create an application

You need to create an application for Casvisor in Casdoor. The application page is at **Identity -> Applications**. And you
can create an application by clicking the `add` button.

![create application](/img/installtion_application.png)

Required fields:

1. `Home`: The host of Casvisor server, e.g. `http://localhost:16001`.
2. `Ognization`: The organization you created in the previous step.
3. `Callback URLs`: The callback URL of Casvisor server, e.g. `http://localhost:16001/callback`. You can add multiple
callback URLs by clicking the `add` button. These are the urls that is allowed to be redirected after login.

![application edit](/img/installtion_application_edit.png)

## Download

The source code of Casvisor is hosted on GitHub: <https://github.com/casbin/casvisor>. Both the Go backend code and React frontend code are contained in a single repository.

| Name | Description | Language | Source code |
|----------|---------------------------------|-----------------------|------------------------------------------------------|
| Frontend | Web frontend UI for Casdoor | JavaScript + React | <https://github.com/casbin/casvisor/tree/master/web> |
| Backend | RESTful API backend for Casdoor | Golang + Beego + XORM | <https://github.com/casbin/casvisor> |

Casvisor supports `Go Modules`. To download the code, simply clone the code using git:

```shell
git clone https://github.com/casbin/casvisor
```

## Configuration

### Backend

The configuration file of Casvisor backend located at `conf/app.conf`. You need to modify the following fields:

#### Database

Modify `dataSourceName` to your own database connection string. Casvisor will create a database named `casvisor` if it doesn't exist.

```ini
driverName = mysql
dataSourceName = root:123456@tcp(localhost:3306)/
dbName = casvisor
```

#### Connect Casdoor

Modify `casdoorEndpoint`, `clientID`, `clientSecret`, `casdoorOrganization` and `casdoorApplication` to your own Casdoor configuration.
You can get the `clientID` and `clientSecret` from the application page that you created in the previous step.

```ini
casdoorEndpoint = http://localhost:8000
clientId = c34fdf145f41313727a8
clientSecret = 615c503d4552d24a40360cf908b6d17e3b7f8832
casdoorOrganization = "casbin"
casdoorApplication = "app-casvisor"
```

### Frontend

In `web/src/conf.js`, you need to modify the following fields:

```javascript
export const AuthConfig = {
serverUrl: "http://localhost:8000",
clientId: "c34fdf145f4131b727a8",
appName: "app-casvisor",
organizationName: "casbin",
redirectPath: "/callback",
};
```

## Run

Before running Casvisor, make sure Casdoor is running.

### Production

In production, you need to build the frontend code first, then run the backend code.

#### Build frontend

```shell
cd web
yarn install
yarn build
```

After building successfully, the frontend bundle will be generated in `web/build` directory.

#### Run backend

```shell
go build
```

Visit backend server at [http://localhost:19000](http://localhost:19000).

### Development

In development, you need to run the frontend code and backend code at the same time.

#### Run frontend

```shell
cd web
yarn install
yarn start
```

#### Run backend

```shell
go build
```

Visit frontend server [http://localhost:16001](http://localhost:16001).
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
link: {type: "generated-index"},
items: [
"overview",
"installation",
{
type: "link",
label: "PDF Download",
Expand Down
Binary file added static/img/installtion_application.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/installtion_application_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/installtion_organization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3c9e6b6

Please sign in to comment.