-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15694f8
commit 3f1759d
Showing
13 changed files
with
224 additions
and
43 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -50,3 +50,4 @@ cfg.json | |
package-lock.json | ||
pnpm-lock.yaml | ||
tsconfig.tsbuildinfo | ||
front-standalone/dist/* |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Open-OAuth2Playground | ||
Open-OAuth2Playground: 简单而好用的开源 OAuth2-Playground | ||
|
||
![](https://github.com/ECNU/Open-OAuth2Playground/blob/main/demo.jpg?raw=true) | ||
|
||
- [Open-OAuth2Playground](#open-oauth2playground) | ||
- [安装运行](#安装运行) | ||
- [二进制直接运行](#二进制直接运行) | ||
- [systemctl 托管](#systemctl-托管) | ||
- [编译打包](#编译打包) | ||
- [后端编译](#后端编译) | ||
- [前端编译](#前端编译) | ||
- [统一打包](#统一打包) | ||
- [配置](#配置) | ||
- [后端配置](#后端配置) | ||
- [前端配置](#前端配置) | ||
- [API](#api) | ||
|
||
|
||
## 安装运行 | ||
|
||
### 二进制直接运行 | ||
在 [release](https://github.com/ECNU/Open-OAuth2Playground/releases) 中下载最新的 [release] 包,解压后直接运行即可。 | ||
|
||
``` | ||
tar -zxvf Open-OAuth2Playground-0.1.0-linux-amd64.tar.gz | ||
cd Open-OAuth2Playground/ | ||
./control start | ||
``` | ||
访问你服务器的 80 端口即可使用。 | ||
|
||
|
||
### systemctl 托管 | ||
假定部署在 `/opt/Open-OAuth2Playground` 目录下,如果部署在其他目录修改 `playground.service` 中的 `WorkingDirectory` 和 `ExecStart` 两个字段即可。 | ||
``` | ||
cp playground.service /etc/systemd/system/ | ||
systemctl daemon-reload | ||
systemctl enable playground | ||
systemctl start playground | ||
``` | ||
|
||
### 编译打包 | ||
获取项目源码 | ||
``` | ||
git clone https://github.com/ECNU/Open-OAuth2Playground.git | ||
``` | ||
#### 后端编译 | ||
``` | ||
cd Open-OAuth2Playground/ | ||
go mod tidy | ||
go build | ||
``` | ||
#### 前端编译 | ||
``` | ||
cd front-standalone/ | ||
pnpm install | ||
pnpm build | ||
``` | ||
#### 统一打包 | ||
``` | ||
cd .. | ||
chmod +x control | ||
./control pack | ||
``` | ||
|
||
### 配置 | ||
#### 后端配置 | ||
修改 `cfg.json` | ||
|
||
#### 前端配置 | ||
修改 `.env.production` | ||
|
||
注意前端的 `route_base` 需要和后端相匹配。 | ||
### API | ||
todo |
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
|
||
WORKSPACE=$(cd $(dirname $0)/; pwd) | ||
cd $WORKSPACE | ||
|
||
mkdir -p var | ||
|
||
app=Open-OAuth2Playground | ||
conf=cfg.json | ||
pidfile=var/app.pid | ||
logfile=var/app.log | ||
|
||
function check_pid() { | ||
if [ -f $pidfile ];then | ||
pid=`cat $pidfile` | ||
if [ -n $pid ]; then | ||
running=`ps -p $pid|grep -v "PID TTY" |wc -l` | ||
return $running | ||
fi | ||
fi | ||
return 0 | ||
} | ||
|
||
function start() { | ||
check_pid | ||
running=$? | ||
if [ $running -gt 0 ];then | ||
echo -n "$app now is running already, pid=" | ||
cat $pidfile | ||
return 1 | ||
fi | ||
|
||
if ! [ -f $conf ];then | ||
echo "Config file $conf doesn't exist, creating one." | ||
cp cfg.example.json $conf | ||
fi | ||
nohup ./$app -c $conf &> $logfile & | ||
echo $! > $pidfile | ||
echo "$app started..., pid=$!" | ||
} | ||
|
||
function stop() { | ||
pid=`cat $pidfile` | ||
kill $pid | ||
echo "$app stoped..." | ||
} | ||
|
||
function restart() { | ||
stop | ||
sleep 1 | ||
start | ||
} | ||
|
||
function status() { | ||
check_pid | ||
running=$? | ||
if [ $running -gt 0 ];then | ||
echo started | ||
else | ||
echo stoped | ||
fi | ||
} | ||
|
||
function tailf() { | ||
tail -f $logfile | ||
} | ||
|
||
function build() { | ||
go build | ||
if [ $? -ne 0 ]; then | ||
exit $? | ||
fi | ||
./$app -v | ||
} | ||
|
||
function pack() { | ||
build | ||
git log -1 --pretty=%h > gitversion | ||
version=`./$app -v` | ||
file_list="front-standalone control cfg.json cfg.json.example $app" | ||
echo "...tar $app-$version.tar.gz <= $file_list" | ||
tar zcf $app-$version.tar.gz gitversion $file_list | ||
} | ||
|
||
|
||
function help() { | ||
echo "$0 build|pack|start|stop|restart|status|tail" | ||
} | ||
|
||
if [ "$1" == "" ]; then | ||
help | ||
elif [ "$1" == "stop" ];then | ||
stop | ||
elif [ "$1" == "start" ];then | ||
start | ||
elif [ "$1" == "restart" ];then | ||
restart | ||
elif [ "$1" == "status" ];then | ||
status | ||
elif [ "$1" == "tail" ];then | ||
tailf | ||
elif [ "$1" == "build" ];then | ||
build | ||
elif [ "$1" == "pack" ];then | ||
pack | ||
else | ||
help | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Router path | ||
VUE_APP_ROUTER_BASE=/playground/ | ||
VUE_APP_ROUTER_BASE=/ | ||
# Api Config | ||
VUE_APP_API_PROTO=http | ||
VUE_APP_API_HOST=localhost | ||
VUE_APP_API_PORT= | ||
VUE_APP_API_ROUTE=/playground/v1 | ||
VUE_APP_API_VERSION=v1 |
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,7 +1,6 @@ | ||
# Router path | ||
VUE_APP_ROUTER_BASE=/playground/ | ||
# Api Config | ||
VUE_APP_API_PROTO=http | ||
VUE_APP_API_HOST=localhost | ||
VUE_APP_ROUTER_BASE=/ | ||
VUE_APP_API_PROTO= | ||
VUE_APP_API_HOST= | ||
VUE_APP_API_PORT= | ||
VUE_APP_API_ROUTE=/playground/v1 | ||
VUE_APP_API_VERSION=v1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[Unit] | ||
Description=playground | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
# modify when deploy in prod env | ||
User=root | ||
Group=root | ||
|
||
Type=simple | ||
ExecStart=/opt/Open-OAuth2Playground/Open-OAuth2Playground | ||
WorkingDirectory=/opt/Open-OAuth2Playground | ||
|
||
Restart=always | ||
RestartSec=1 | ||
StartLimitInterval=0 | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|