Browse Source

Merge branch 'dev' of https://git.tonyandmoney.cn/tuonian/nginx-ui into dev

niantuo 1 year ago
parent
commit
c9b727ef35

+ 3 - 1
.gitignore

@@ -38,4 +38,6 @@ server/data/sessions
 
 /data/sessions
 /conf/app.local.conf
-/build/
+/build/
+
+frontend/.idea

+ 6 - 3
README.md

@@ -1,13 +1,16 @@
-# nginx-ui desktop
+# nginx-ui
+nginx可视化配置
+
+## nginx-ui desktop
 
 参考文档: https://wails.io/zh-Hans/docs/reference/project-config
 
-## 开发
+### 开发
 ```shell
 wails dev
 ```
 
-## 打包
+### 打包
 ```shell
 ## 生产版本
 wails build -webview2=embed

+ 8 - 8
conf/app.conf

@@ -25,11 +25,11 @@ thirdsessionname =
 thirdsessioncheckurl =
 
 
-oauth2_client_id =
-oauth2_client_secret =
-oauth2_authorize_endpoint =
-oauth2_token_endpoint =
-oauth2_redirect_uri =
-oauth2_scopes = ""
-oauth2_userinfo =
-oauth2_enable = false
+oauth2_client_id = XVlBzgbaiCMRAjWw111
+oauth2_client_secret = XVlBzgbaiCMRAjWw123
+oauth2_authorize_endpoint = https://api.tonyandmoney.cn/oauth/authorize
+oauth2_token_endpoint = https://api.tonyandmoney.cn/oauth/token
+oauth2_redirect_uri = http://127.0.0.1:5173/
+oauth2_scopes = "userinfo"
+oauth2_userinfo = https://api.tonyandmoney.cn/oauth/user
+oauth2_enable = true

BIN
data/db/sqlite.db


File diff suppressed because it is too large
+ 0 - 0
frontend/dist/assets/index-1fb20f5f.js


+ 1 - 1
frontend/dist/index.html

@@ -4,7 +4,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>NginxUI</title>
     <script type="application/javascript" src="./config.js"></script>
-    <script crossorigin="">import('/nginx-ui/assets/index-8a63c82a.js').finally(() => {
+    <script crossorigin="">import('/nginx-ui/assets/index-1fb20f5f.js').finally(() => {
             
     const qiankunLifeCycle = window.moudleQiankunAppLifeCycles && window.moudleQiankunAppLifeCycles['nginx-ui'];
     if (qiankunLifeCycle) {

+ 13 - 0
frontend/src/pages/error/index.tsx

@@ -0,0 +1,13 @@
+/**
+ * @author tuonian
+ * @date 2023/12/18
+ */
+import './less.less'
+
+
+export const ErrorPage = () => {
+
+  return (<div className="error-page">
+
+  </div>)
+}

+ 3 - 0
frontend/src/pages/error/less.less

@@ -0,0 +1,3 @@
+.error-page{
+
+}

+ 2 - 0
frontend/src/routes/index.tsx

@@ -23,6 +23,7 @@ import {SignupPage} from "../pages/signup";
 import {UserActions} from "../store/slice/user.ts";
 import dayjs from "dayjs";
 import {SSOWrapper} from "../pages/login/sso.tsx";
+import {ErrorPage} from "../pages/error";
 
 /**
  * @author tuonian
@@ -155,6 +156,7 @@ export const MyRouter = () => {
                            )
                        })
                    }
+                   <Route path="/error" Component={ErrorPage} />
                    <Route path="/login" Component={LoginPage} />
                    <Route path="/signup" Component={SignupPage} />
                </Routes>

+ 2 - 2
frontend/vite.config.ts

@@ -53,8 +53,8 @@ export default defineConfig(({command, mode})=>{
           }
         } : {
           "/api":{
-            target: 'http://10.10.0.1:8080',
-            // target: 'http://127.0.0.1:8080',
+            // target: 'http://10.10.0.1:8080',
+            target: 'http://127.0.0.1:8080',
             rewrite: path => path.replace(/^\/api/,"")
           }
         }

+ 7 - 4
server/config/config.go

@@ -38,9 +38,11 @@ var OauthConfig = &CompleteOauth2Config{
 	Config: &oauth2.Config{
 		ClientID:     "",
 		ClientSecret: "",
-		Endpoint:     oauth2.Endpoint{},
-		RedirectURL:  "",
-		Scopes:       []string{},
+		Endpoint: oauth2.Endpoint{
+			AuthStyle: oauth2.AuthStyleInParams,
+		},
+		RedirectURL: "",
+		Scopes:      []string{},
 	},
 }
 
@@ -91,11 +93,12 @@ func init() {
 
 	authorizeEndpoint := beego.AppConfig.DefaultString("oauth2_authorize_endpoint", "")
 	tokenEndpoint := beego.AppConfig.DefaultString("oauth2_token_endpoint", "")
+	authStyle := beego.AppConfig.DefaultInt("oauth2_auth_style", 1)
 
 	OauthConfig.Endpoint = oauth2.Endpoint{
 		AuthURL:   authorizeEndpoint,
 		TokenURL:  tokenEndpoint,
-		AuthStyle: 0,
+		AuthStyle: oauth2.AuthStyle(authStyle),
 	}
 	OauthConfig.RedirectURL = beego.AppConfig.DefaultString("oauth2_redirect_uri", "")
 	OauthConfig.Scopes = beego.AppConfig.DefaultStrings("oauth2_scopes", []string{})

+ 3 - 2
server/controllers/oauth2.go

@@ -71,13 +71,14 @@ func (c *Oauth2Controller) Callback() {
 	err = json.Unmarshal(content, &user)
 	if err != nil {
 		logs.Error("GetUserinfo Unmarshal", err)
-		c.setCode(-1).setMsg(fmt.Sprintf("登录失败(Unmarshal):%s", err.Error())).json()
-		return
 	}
 	if len(user.Account) == 0 {
 		c.setCode(-1).setMsg("登录失败,请确认userinfo接口返回了account字段").json()
 		return
 	}
+	if len(user.Nickname) == 0 {
+		user.Nickname = user.Account
+	}
 	o := orm.NewOrm()
 	err = o.Read(&user, "Account")
 	if err != nil {

+ 1 - 1
server/middleware/auth.go

@@ -55,7 +55,7 @@ func checkThirdSession(ctx *context.Context, sess session.Store) {
 }
 
 func AuthFilter(ctx *context.Context) {
-	path := ctx.Request.RequestURI
+	path := ctx.Request.URL.Path
 	path = strings.TrimSuffix(path, "/")
 	path = strings.TrimPrefix(path, config.Config.BaseApi)
 	if whitelist[path] {

+ 2 - 0
server/routers/router.go

@@ -26,6 +26,8 @@ func init() {
 
 	userController := controllers.NewUserController()
 
+	logs.Info("baseApi", config.BaseApi)
+
 	ns := beego.NewNamespace(config.BaseApi,
 		beego.NSRouter(NginxR, &controllers.NginxController{}),
 		beego.NSRouter(NginxGetR, &controllers.NginxController{}, "post:Update"),

Some files were not shown because too many files changed in this diff