ソースを参照

refactor: casdoor settings

0xJacky 1 年間 前
コミット
37fa8b899f

+ 103 - 105
api/user/auth.go

@@ -1,131 +1,129 @@
 package user
 
 import (
-	"fmt"
-	"github.com/0xJacky/Nginx-UI/api"
-	"github.com/0xJacky/Nginx-UI/model"
-	"github.com/0xJacky/Nginx-UI/settings"
-	"net/http"
+    "github.com/0xJacky/Nginx-UI/api"
+    "github.com/0xJacky/Nginx-UI/model"
+    "github.com/0xJacky/Nginx-UI/settings"
+    "net/http"
 
-	"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
-	"github.com/gin-gonic/gin"
-	"github.com/pkg/errors"
-	"golang.org/x/crypto/bcrypt"
-	"gorm.io/gorm"
+    "github.com/casdoor/casdoor-go-sdk/casdoorsdk"
+    "github.com/gin-gonic/gin"
+    "github.com/pkg/errors"
+    "golang.org/x/crypto/bcrypt"
+    "gorm.io/gorm"
 )
 
 type LoginUser struct {
-	Name     string `json:"name" binding:"required,max=255"`
-	Password string `json:"password" binding:"required,max=255"`
+    Name     string `json:"name" binding:"required,max=255"`
+    Password string `json:"password" binding:"required,max=255"`
 }
 
 func Login(c *gin.Context) {
-	var user LoginUser
-	ok := api.BindAndValid(c, &user)
-	if !ok {
-		return
-	}
+    var user LoginUser
+    ok := api.BindAndValid(c, &user)
+    if !ok {
+        return
+    }
 
-	u, _ := model.GetUser(user.Name)
+    u, _ := model.GetUser(user.Name)
 
-	if err := bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(user.Password)); err != nil {
-		c.JSON(http.StatusForbidden, gin.H{
-			"message": "The username or password is incorrect",
-		})
-		return
-	}
+    if err := bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(user.Password)); err != nil {
+        c.JSON(http.StatusForbidden, gin.H{
+            "message": "The username or password is incorrect",
+        })
+        return
+    }
 
-	token, err := model.GenerateJWT(u.Name)
-	if err != nil {
-		c.JSON(http.StatusInternalServerError, gin.H{
-			"message": err.Error(),
-		})
-		return
-	}
+    token, err := model.GenerateJWT(u.Name)
+    if err != nil {
+        c.JSON(http.StatusInternalServerError, gin.H{
+            "message": err.Error(),
+        })
+        return
+    }
 
-	c.JSON(http.StatusOK, gin.H{
-		"message": "ok",
-		"token":   token,
-	})
+    c.JSON(http.StatusOK, gin.H{
+        "message": "ok",
+        "token":   token,
+    })
 }
 
 func Logout(c *gin.Context) {
-	token := c.GetHeader("Authorization")
-	if token != "" {
-		err := model.DeleteToken(token)
-		if err != nil {
-			c.JSON(http.StatusInternalServerError, gin.H{
-				"message": err.Error(),
-			})
-			return
-		}
-	}
-	c.JSON(http.StatusNoContent, nil)
+    token := c.GetHeader("Authorization")
+    if token != "" {
+        err := model.DeleteToken(token)
+        if err != nil {
+            c.JSON(http.StatusInternalServerError, gin.H{
+                "message": err.Error(),
+            })
+            return
+        }
+    }
+    c.JSON(http.StatusNoContent, nil)
 }
 
 type CasdoorLoginUser struct {
-	Code  string `json:"code" binding:"required,max=255"`
-	State string `json:"state" binding:"required,max=255"`
+    Code  string `json:"code" binding:"required,max=255"`
+    State string `json:"state" binding:"required,max=255"`
 }
 
 func CasdoorCallback(c *gin.Context) {
-	var loginUser CasdoorLoginUser
-	fmt.Println("CasdoorCallback called")
-	ok := api.BindAndValid(c, &loginUser)
-	if !ok {
-		return
-	}
-	endpoint := settings.ServerSettings.CasdoorEndpoint
-	clientId := settings.ServerSettings.CasdoorClientId
-	clientSecret := settings.ServerSettings.CasdoorClientSecret
-	certificate := settings.ServerSettings.CasdoorCertificate
-	organization := settings.ServerSettings.CasdoorOrganization
-	application := settings.ServerSettings.CasdoorApplication
-	if endpoint == "" || clientId == "" || clientSecret == "" || certificate == "" || organization == "" || application == "" {
-		c.JSON(http.StatusInternalServerError, gin.H{
-			"message": "Casdoor is not configured",
-		})
-		return
-	}
-	casdoorsdk.InitConfig(endpoint, clientId, clientSecret, certificate, organization, application)
-	token, err := casdoorsdk.GetOAuthToken(loginUser.Code, loginUser.State)
-	if err != nil {
-		c.JSON(http.StatusInternalServerError, gin.H{
-			"message": err.Error(),
-		})
-		return
-	}
-	claims, err := casdoorsdk.ParseJwtToken(token.AccessToken)
-	if err != nil {
-		c.JSON(http.StatusInternalServerError, gin.H{
-			"message": err.Error(),
-		})
-		return
-	}
-	u, err := model.GetUser(claims.Name)
-	if err != nil {
-		if errors.Is(err, gorm.ErrRecordNotFound) {
-			c.JSON(http.StatusForbidden, gin.H{
-				"message": "User not exist",
-			})
-		} else {
-			c.JSON(http.StatusInternalServerError, gin.H{
-				"message": err.Error(),
-			})
-		}
-		return
-	}
+    var loginUser CasdoorLoginUser
+    ok := api.BindAndValid(c, &loginUser)
+    if !ok {
+        return
+    }
+    endpoint := settings.CasdoorSettings.Endpoint
+    clientId := settings.CasdoorSettings.ClientId
+    clientSecret := settings.CasdoorSettings.ClientSecret
+    certificate := settings.CasdoorSettings.Certificate
+    organization := settings.CasdoorSettings.Organization
+    application := settings.CasdoorSettings.Application
+    if endpoint == "" || clientId == "" || clientSecret == "" || certificate == "" || organization == "" || application == "" {
+        c.JSON(http.StatusInternalServerError, gin.H{
+            "message": "Casdoor is not configured",
+        })
+        return
+    }
+    casdoorsdk.InitConfig(endpoint, clientId, clientSecret, certificate, organization, application)
+    token, err := casdoorsdk.GetOAuthToken(loginUser.Code, loginUser.State)
+    if err != nil {
+        c.JSON(http.StatusInternalServerError, gin.H{
+            "message": err.Error(),
+        })
+        return
+    }
+    claims, err := casdoorsdk.ParseJwtToken(token.AccessToken)
+    if err != nil {
+        c.JSON(http.StatusInternalServerError, gin.H{
+            "message": err.Error(),
+        })
+        return
+    }
+    u, err := model.GetUser(claims.Name)
+    if err != nil {
+        if errors.Is(err, gorm.ErrRecordNotFound) {
+            c.JSON(http.StatusForbidden, gin.H{
+                "message": "User not exist",
+            })
+        } else {
+            c.JSON(http.StatusInternalServerError, gin.H{
+                "message": err.Error(),
+            })
+        }
+        return
+    }
 
-	userToken, err := model.GenerateJWT(u.Name)
-	if err != nil {
-		c.JSON(http.StatusInternalServerError, gin.H{
-			"message": err.Error(),
-		})
-		return
-	}
+    userToken, err := model.GenerateJWT(u.Name)
+    if err != nil {
+        c.JSON(http.StatusInternalServerError, gin.H{
+            "message": err.Error(),
+        })
+        return
+    }
 
-	c.JSON(http.StatusOK, gin.H{
-		"message": "ok",
-		"token":   userToken,
-	})
+    c.JSON(http.StatusOK, gin.H{
+        "message": "ok",
+        "token":   userToken,
+    })
 }

+ 9 - 10
api/user/casdoor.go

@@ -1,19 +1,18 @@
 package user
 
 import (
-    "fmt"
-    "github.com/0xJacky/Nginx-UI/settings"
-    "github.com/gin-gonic/gin"
-    "net/http"
-    "net/url"
+	"fmt"
+	"github.com/0xJacky/Nginx-UI/settings"
+	"github.com/gin-gonic/gin"
+	"net/http"
+	"net/url"
 )
 
 func GetCasdoorUri(c *gin.Context) {
-	endpoint := settings.ServerSettings.CasdoorEndpoint
-	clientId := settings.ServerSettings.CasdoorClientId
-	redirectUri := settings.ServerSettings.CasdoorRedirectUri
-	state := settings.ServerSettings.CasdoorApplication
-	fmt.Println(redirectUri)
+	endpoint := settings.CasdoorSettings.Endpoint
+	clientId := settings.CasdoorSettings.ClientId
+	redirectUri := settings.CasdoorSettings.RedirectUri
+	state := settings.CasdoorSettings.Application
 	if endpoint == "" || clientId == "" || redirectUri == "" || state == "" {
 		c.JSON(http.StatusOK, gin.H{
 			"uri": "",

+ 8 - 13
app.example.ini

@@ -8,13 +8,6 @@ StartCmd = login
 Database = database
 CADir =
 Demo =
-CasdoorEndpoint =
-CasdoorClientId =
-CasdoorClientSecret =
-CasdoorCertificate =
-CasdoorOrganization =
-CasdoorApplication =
-CasdoorRedirectUri =
 
 [nginx]
 AccessLogPath = /var/log/nginx/access.log
@@ -31,9 +24,11 @@ BaseUrl =
 Proxy =
 Token =
 
-[git]
-Url =
-AuthMethod =
-Username =
-Password =
-PrivateKeyFile =
+[casdoor]
+Endpoint =
+ClientId =
+ClientSecret =
+Certificate =
+Organization =
+Application =
+RedirectUri =

+ 0 - 1
app/.idea/inspectionProfiles/Project_Default.xml

@@ -2,6 +2,5 @@
   <profile version="1.0">
     <option name="myName" value="Project Default" />
     <inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" />
-    <inspection_tool class="StandardJS" enabled="true" level="ERROR" enabled_by_default="true" />
   </profile>
 </component>

+ 1 - 1
app/.idea/jsLinters/eslint.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="EslintConfiguration">
-    <custom-configuration-file used="true" path="$PROJECT_DIR$/.eslintrc.js" />
+    <custom-configuration-file used="false" path="$PROJECT_DIR$/.eslintrc.cjs" />
     <option name="fix-on-save" value="true" />
   </component>
 </project>

+ 109 - 108
go.mod

@@ -7,47 +7,48 @@ toolchain go1.21.0
 require (
 	github.com/0xJacky/pofile v0.2.1
 	github.com/BurntSushi/toml v1.3.2
-	github.com/casdoor/casdoor-go-sdk v0.32.1
-	github.com/creack/pty v1.1.20
+	github.com/casdoor/casdoor-go-sdk v0.34.0
+	github.com/creack/pty v1.1.21
 	github.com/dustin/go-humanize v1.0.1
-	github.com/fatih/color v1.15.0
+	github.com/fatih/color v1.16.0
 	github.com/gin-contrib/static v0.0.1
 	github.com/gin-gonic/gin v1.9.1
-	github.com/go-acme/lego/v4 v4.14.0
+	github.com/go-acme/lego/v4 v4.14.2
 	github.com/go-co-op/gocron v1.36.0
-	github.com/go-playground/validator/v10 v10.15.3
+	github.com/go-playground/validator/v10 v10.16.0
 	github.com/golang-jwt/jwt v3.2.2+incompatible
 	github.com/google/uuid v1.4.0
-	github.com/gorilla/websocket v1.5.0
+	github.com/gorilla/websocket v1.5.1
 	github.com/hpcloud/tail v1.0.0
 	github.com/jpillora/overseer v1.1.6
 	github.com/lib/pq v1.10.9
+	github.com/mitchellh/mapstructure v1.5.0
 	github.com/pkg/errors v0.9.1
 	github.com/pretty66/websocketproxy v0.0.0-20220507015215-930b3a686308
-	github.com/sashabaranov/go-openai v1.15.1
-	github.com/shirou/gopsutil/v3 v3.23.8
-	github.com/spf13/cast v1.5.1
-	github.com/tufanbarisyildirim/gonginx v0.0.0-20230627120331-964b6ae8380e
-	github.com/unknwon/com v1.0.1
-	go.uber.org/zap v1.25.0
-	golang.org/x/crypto v0.14.0
+	github.com/sashabaranov/go-openai v1.17.9
+	github.com/shirou/gopsutil/v3 v3.23.11
+	github.com/shopspring/decimal v1.3.1
+	github.com/spf13/cast v1.6.0
+	github.com/tufanbarisyildirim/gonginx v0.0.0-20231116154738-5dd06bb2938b
+	go.uber.org/zap v1.26.0
+	golang.org/x/crypto v0.16.0
 	gopkg.in/ini.v1 v1.67.0
-	gorm.io/driver/sqlite v1.5.3
+	gorm.io/driver/sqlite v1.5.4
 	gorm.io/gen v0.3.23
-	gorm.io/gorm v1.25.4
-	gorm.io/plugin/dbresolver v1.4.7
+	gorm.io/gorm v1.25.5
+	gorm.io/plugin/dbresolver v1.5.0
 )
 
 require (
-	cloud.google.com/go/compute v1.23.0 // indirect
+	cloud.google.com/go/compute v1.23.3 // indirect
 	cloud.google.com/go/compute/metadata v0.2.3 // indirect
 	github.com/AdamSLevy/jsonrpc2/v14 v14.1.0 // indirect
 	github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0 // indirect
-	github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.1.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 // indirect
+	github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.2.0 // indirect
 	github.com/Azure/go-autorest v14.2.0+incompatible // indirect
 	github.com/Azure/go-autorest/autorest v0.11.29 // indirect
 	github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
@@ -65,56 +66,57 @@ require (
 	github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
 	github.com/StackExchange/wmi v1.2.1 // indirect
 	github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 // indirect
-	github.com/aliyun/alibaba-cloud-sdk-go v1.62.540 // indirect
-	github.com/andybalholm/brotli v1.0.5 // indirect
+	github.com/aliyun/alibaba-cloud-sdk-go v1.62.619 // indirect
+	github.com/andybalholm/brotli v1.0.6 // indirect
 	github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
-	github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect
-	github.com/aws/aws-sdk-go-v2/config v1.18.39 // indirect
-	github.com/aws/aws-sdk-go-v2/credentials v1.13.37 // indirect
-	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect
-	github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
-	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect
-	github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect
-	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect
-	github.com/aws/aws-sdk-go-v2/service/lightsail v1.28.5 // indirect
-	github.com/aws/aws-sdk-go-v2/service/route53 v1.29.5 // indirect
-	github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 // indirect
-	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.6 // indirect
-	github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect
-	github.com/aws/smithy-go v1.14.2 // indirect
+	github.com/aws/aws-sdk-go-v2 v1.23.5 // indirect
+	github.com/aws/aws-sdk-go-v2/config v1.25.11 // indirect
+	github.com/aws/aws-sdk-go-v2/credentials v1.16.9 // indirect
+	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.9 // indirect
+	github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.8 // indirect
+	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.8 // indirect
+	github.com/aws/aws-sdk-go-v2/internal/ini v1.7.1 // indirect
+	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.3 // indirect
+	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.8 // indirect
+	github.com/aws/aws-sdk-go-v2/service/lightsail v1.32.2 // indirect
+	github.com/aws/aws-sdk-go-v2/service/route53 v1.35.2 // indirect
+	github.com/aws/aws-sdk-go-v2/service/sso v1.18.2 // indirect
+	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.2 // indirect
+	github.com/aws/aws-sdk-go-v2/service/sts v1.26.2 // indirect
+	github.com/aws/smithy-go v1.18.1 // indirect
 	github.com/aymerick/douceur v0.2.0 // indirect
 	github.com/benbjohnson/clock v1.3.5 // indirect
 	github.com/boombuler/barcode v1.0.1 // indirect
-	github.com/bytedance/sonic v1.10.0 // indirect
+	github.com/bytedance/sonic v1.10.2 // indirect
 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
 	github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
-	github.com/chenzhuoyu/iasm v0.9.0 // indirect
-	github.com/civo/civogo v0.3.45 // indirect
-	github.com/cloudflare/cloudflare-go v0.76.0 // indirect
+	github.com/chenzhuoyu/iasm v0.9.1 // indirect
+	github.com/civo/civogo v0.3.53 // indirect
+	github.com/cloudflare/cloudflare-go v0.82.0 // indirect
 	github.com/cpu/goacmedns v0.1.1 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/deepmap/oapi-codegen v1.14.0 // indirect
+	github.com/deepmap/oapi-codegen v1.16.2 // indirect
 	github.com/dimchansky/utfbom v1.1.1 // indirect
-	github.com/dnsimple/dnsimple-go v1.4.0 // indirect
+	github.com/dnsimple/dnsimple-go v1.5.1 // indirect
 	github.com/exoscale/egoscale v0.100.1 // indirect
 	github.com/fatih/structs v1.1.0 // indirect
 	github.com/flosch/pongo2/v4 v4.0.2 // indirect
-	github.com/fsnotify/fsnotify v1.6.0 // indirect
-	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
+	github.com/fsnotify/fsnotify v1.7.0 // indirect
+	github.com/gabriel-vasile/mimetype v1.4.3 // indirect
 	github.com/ghodss/yaml v1.0.0 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
-	github.com/go-errors/errors v1.4.2 // indirect
+	github.com/go-errors/errors v1.5.1 // indirect
 	github.com/go-jose/go-jose/v3 v3.0.1 // indirect
-	github.com/go-logr/logr v1.2.4 // indirect
+	github.com/go-logr/logr v1.3.0 // indirect
 	github.com/go-ole/go-ole v1.3.0 // indirect
 	github.com/go-playground/locales v0.14.1 // indirect
 	github.com/go-playground/universal-translator v0.18.1 // indirect
-	github.com/go-resty/resty/v2 v2.7.0 // indirect
+	github.com/go-resty/resty/v2 v2.10.0 // indirect
 	github.com/go-sql-driver/mysql v1.7.1 // indirect
 	github.com/goccy/go-json v0.10.2 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
 	github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
-	github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
+	github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
 	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
@@ -122,15 +124,15 @@ require (
 	github.com/google/go-querystring v1.1.0 // indirect
 	github.com/google/gofuzz v1.2.0 // indirect
 	github.com/google/s2a-go v0.1.7 // indirect
-	github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
+	github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
 	github.com/googleapis/gax-go/v2 v2.12.0 // indirect
-	github.com/gophercloud/gophercloud v1.6.0 // indirect
-	github.com/gophercloud/utils v0.0.0-20230523080330-de873b9cf00d // indirect
-	github.com/gorilla/css v1.0.0 // indirect
+	github.com/gophercloud/gophercloud v1.8.0 // indirect
+	github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 // indirect
+	github.com/gorilla/css v1.0.1 // indirect
 	github.com/hashicorp/errwrap v1.1.0 // indirect
 	github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
 	github.com/hashicorp/go-multierror v1.1.1 // indirect
-	github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
+	github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
 	github.com/hashicorp/go-uuid v1.0.3 // indirect
 	github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
 	github.com/infobloxopen/infoblox-go-client v1.1.1 // indirect
@@ -143,51 +145,50 @@ require (
 	github.com/jpillora/s3 v1.1.4 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
-	github.com/kataras/blocks v0.0.7 // indirect
-	github.com/kataras/golog v0.1.9 // indirect
-	github.com/kataras/iris/v12 v12.2.5 // indirect
-	github.com/kataras/pio v0.0.12 // indirect
+	github.com/kataras/blocks v0.0.8 // indirect
+	github.com/kataras/golog v0.1.11 // indirect
+	github.com/kataras/iris/v12 v12.2.8 // indirect
+	github.com/kataras/pio v0.0.13 // indirect
 	github.com/kataras/sitemap v0.0.6 // indirect
 	github.com/kataras/tunnel v0.0.4 // indirect
-	github.com/klauspost/compress v1.16.7 // indirect
-	github.com/klauspost/cpuid/v2 v2.2.5 // indirect
+	github.com/klauspost/compress v1.17.4 // indirect
+	github.com/klauspost/cpuid/v2 v2.2.6 // indirect
 	github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b // indirect
 	github.com/kylelemons/godebug v1.1.0 // indirect
 	github.com/labbsr0x/bindman-dns-webhook v1.0.2 // indirect
 	github.com/labbsr0x/goh v1.0.1 // indirect
-	github.com/labstack/echo/v4 v4.11.1 // indirect
-	github.com/labstack/gommon v0.4.0 // indirect
+	github.com/labstack/echo/v4 v4.11.3 // indirect
+	github.com/labstack/gommon v0.4.1 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
-	github.com/linode/linodego v1.21.0 // indirect
-	github.com/liquidweb/go-lwApi v0.0.5 // indirect
-	github.com/liquidweb/liquidweb-cli v0.6.10 // indirect
-	github.com/liquidweb/liquidweb-go v1.6.3 // indirect
-	github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
+	github.com/linode/linodego v1.25.0 // indirect
+	github.com/liquidweb/liquidweb-cli v0.7.0 // indirect
+	github.com/liquidweb/liquidweb-go v1.6.4 // indirect
+	github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
 	github.com/mailgun/raymond/v2 v2.0.48 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
-	github.com/mattn/go-isatty v0.0.19 // indirect
-	github.com/mattn/go-sqlite3 v1.14.17 // indirect
-	github.com/microcosm-cc/bluemonday v1.0.25 // indirect
-	github.com/miekg/dns v1.1.55 // indirect
+	github.com/mattn/go-isatty v0.0.20 // indirect
+	github.com/mattn/go-sqlite3 v1.14.18 // indirect
+	github.com/microcosm-cc/bluemonday v1.0.26 // indirect
+	github.com/miekg/dns v1.1.57 // indirect
 	github.com/mimuret/golang-iij-dpf v0.9.1 // indirect
 	github.com/mitchellh/go-homedir v1.1.0 // indirect
-	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 // indirect
 	github.com/nrdcg/auroradns v1.1.0 // indirect
+	github.com/nrdcg/bunny-go v0.0.0-20230728143221-c9dda82568d9 // indirect
 	github.com/nrdcg/desec v0.7.0 // indirect
 	github.com/nrdcg/dnspod-go v0.4.0 // indirect
 	github.com/nrdcg/freemyip v0.2.0 // indirect
-	github.com/nrdcg/goinwx v0.8.2 // indirect
+	github.com/nrdcg/goinwx v0.10.0 // indirect
 	github.com/nrdcg/namesilo v0.2.1 // indirect
 	github.com/nrdcg/nodion v0.1.0 // indirect
 	github.com/nrdcg/porkbun v0.3.0 // indirect
 	github.com/nzdjb/go-metaname v1.0.0 // indirect
 	github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
 	github.com/oracle/oci-go-sdk v24.3.0+incompatible // indirect
-	github.com/ovh/go-ovh v1.4.2 // indirect
+	github.com/ovh/go-ovh v1.4.3 // indirect
 	github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
 	github.com/pelletier/go-toml/v2 v2.1.0 // indirect
 	github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
@@ -200,54 +201,54 @@ require (
 	github.com/sacloud/go-http v0.1.7 // indirect
 	github.com/sacloud/iaas-api-go v1.11.1 // indirect
 	github.com/sacloud/packages-go v0.0.9 // indirect
-	github.com/scaleway/scaleway-sdk-go v1.0.0-beta.20 // indirect
+	github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21 // indirect
 	github.com/schollz/closestmatch v2.1.0+incompatible // indirect
 	github.com/shoenig/go-m1cpu v0.1.6 // indirect
-	github.com/simplesurance/bunny-go v0.0.0-20230727134852-2e9f020229f4 // indirect
 	github.com/sirupsen/logrus v1.9.3 // indirect
 	github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 // indirect
 	github.com/softlayer/softlayer-go v1.1.2 // indirect
 	github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect
 	github.com/stretchr/objx v0.5.1 // indirect
 	github.com/stretchr/testify v1.8.4 // indirect
-	github.com/tdewolff/minify/v2 v2.12.9 // indirect
-	github.com/tdewolff/parse/v2 v2.6.8 // indirect
-	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.742 // indirect
-	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.742 // indirect
-	github.com/tklauser/go-sysconf v0.3.12 // indirect
-	github.com/tklauser/numcpus v0.6.1 // indirect
-	github.com/transip/gotransip/v6 v6.21.0 // indirect
+	github.com/tdewolff/minify/v2 v2.20.8 // indirect
+	github.com/tdewolff/parse/v2 v2.7.6 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.808 // indirect
+	github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.808 // indirect
+	github.com/tklauser/go-sysconf v0.3.13 // indirect
+	github.com/tklauser/numcpus v0.7.0 // indirect
+	github.com/transip/gotransip/v6 v6.23.0 // indirect
 	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
-	github.com/ugorji/go/codec v1.2.11 // indirect
-	github.com/ultradns/ultradns-go-sdk v1.5.0-20230427130837-23c9b0c // indirect
+	github.com/ugorji/go/codec v1.2.12 // indirect
+	github.com/ultradns/ultradns-go-sdk v1.6.1-20231103022937-8589b6a // indirect
 	github.com/valyala/bytebufferpool v1.0.0 // indirect
 	github.com/valyala/fasttemplate v1.2.2 // indirect
 	github.com/vinyldns/go-vinyldns v0.9.16 // indirect
-	github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
+	github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
 	github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
 	github.com/vultr/govultr/v2 v2.17.2 // indirect
-	github.com/yandex-cloud/go-genproto v0.0.0-20230904091001-eb19f2895318 // indirect
-	github.com/yandex-cloud/go-sdk v0.0.0-20230831120744-c3a3ae28d8ae // indirect
+	github.com/yandex-cloud/go-genproto v0.0.0-20231127094019-88b7907145d1 // indirect
+	github.com/yandex-cloud/go-sdk v0.0.0-20231127094424-0eba64a6b9f1 // indirect
 	github.com/yosssi/ace v0.0.5 // indirect
 	github.com/yusufpapurcu/wmi v1.2.3 // indirect
 	go.opencensus.io v0.24.0 // indirect
 	go.uber.org/atomic v1.11.0 // indirect
 	go.uber.org/multierr v1.11.0 // indirect
 	go.uber.org/ratelimit v0.3.0 // indirect
-	golang.org/x/arch v0.5.0 // indirect
-	golang.org/x/mod v0.12.0 // indirect
-	golang.org/x/net v0.17.0 // indirect
-	golang.org/x/oauth2 v0.13.0 // indirect
-	golang.org/x/sys v0.13.0 // indirect
-	golang.org/x/text v0.13.0 // indirect
-	golang.org/x/time v0.3.0 // indirect
-	golang.org/x/tools v0.13.0 // indirect
-	google.golang.org/api v0.138.0 // indirect
+	golang.org/x/arch v0.6.0 // indirect
+	golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
+	golang.org/x/mod v0.14.0 // indirect
+	golang.org/x/net v0.19.0 // indirect
+	golang.org/x/oauth2 v0.15.0 // indirect
+	golang.org/x/sys v0.15.0 // indirect
+	golang.org/x/text v0.14.0 // indirect
+	golang.org/x/time v0.5.0 // indirect
+	golang.org/x/tools v0.16.0 // indirect
+	google.golang.org/api v0.152.0 // indirect
 	google.golang.org/appengine v1.6.8 // indirect
-	google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
-	google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
-	google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
-	google.golang.org/grpc v1.57.1 // indirect
+	google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
+	google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
+	google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
+	google.golang.org/grpc v1.59.0 // indirect
 	google.golang.org/protobuf v1.31.0 // indirect
 	gopkg.in/fsnotify.v1 v1.4.7 // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect
@@ -256,14 +257,14 @@ require (
 	gopkg.in/yaml.v2 v2.4.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	gorm.io/datatypes v1.2.0 // indirect
-	gorm.io/driver/mysql v1.5.1 // indirect
+	gorm.io/driver/mysql v1.5.2 // indirect
 	gorm.io/hints v1.1.2 // indirect
-	k8s.io/api v0.28.1 // indirect
-	k8s.io/apimachinery v0.28.1 // indirect
-	k8s.io/klog/v2 v2.100.1 // indirect
-	k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
+	k8s.io/api v0.28.4 // indirect
+	k8s.io/apimachinery v0.28.4 // indirect
+	k8s.io/klog/v2 v2.110.1 // indirect
+	k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
 	sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
-	sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
 )
 
 replace gopkg.in/ns1/ns1-go.v2 v2.7.8 => gopkg.in/ns1/ns1-go.v2 v2.7.6

ファイルの差分が大きいため隠しています
+ 746 - 83
go.sum


+ 21 - 0
settings/casdoor.go

@@ -0,0 +1,21 @@
+package settings
+
+type Casdoor struct {
+	Endpoint     string `json:"endpoint"`
+	ClientId     string `json:"client_id"`
+	ClientSecret string `json:"client_secret"`
+	Certificate  string `json:"certificate"`
+	Organization string `json:"organization"`
+	Application  string `json:"application"`
+	RedirectUri  string `json:"redirect_uri"`
+}
+
+var CasdoorSettings = Casdoor{
+	Endpoint:     "",
+	ClientId:     "",
+	ClientSecret: "",
+	Certificate:  "",
+	Organization: "",
+	Application:  "",
+	RedirectUri:  "",
+}

+ 16 - 0
settings/nginx.go

@@ -0,0 +1,16 @@
+package settings
+
+type Nginx struct {
+	AccessLogPath string `json:"access_log_path"`
+	ErrorLogPath  string `json:"error_log_path"`
+	ConfigDir     string `json:"config_dir"`
+	PIDPath       string `json:"pid_path"`
+	TestConfigCmd string `json:"test_config_cmd"`
+	ReloadCmd     string `json:"reload_cmd"`
+	RestartCmd    string `json:"restart_cmd"`
+}
+
+var NginxSettings = Nginx{
+	AccessLogPath: "",
+	ErrorLogPath:  "",
+}

+ 10 - 0
settings/openai.go

@@ -0,0 +1,10 @@
+package settings
+
+type OpenAI struct {
+	BaseUrl string `json:"base_url"`
+	Token   string `json:"token"`
+	Proxy   string `json:"proxy"`
+	Model   string `json:"model"`
+}
+
+var OpenAISettings = OpenAI{}

+ 30 - 0
settings/server.go

@@ -0,0 +1,30 @@
+package settings
+
+type Server struct {
+	HttpHost          string `json:"http_host"`
+	HttpPort          string `json:"http_port"`
+	RunMode           string `json:"run_mode"`
+	JwtSecret         string `json:"jwt_secret"`
+	NodeSecret        string `json:"node_secret"`
+	HTTPChallengePort string `json:"http_challenge_port"`
+	Email             string `json:"email"`
+	Database          string `json:"database"`
+	StartCmd          string `json:"start_cmd"`
+	CADir             string `json:"ca_dir"`
+	Demo              bool   `json:"demo"`
+	PageSize          int    `json:"page_size"`
+	GithubProxy       string `json:"github_proxy"`
+}
+
+var ServerSettings = Server{
+	HttpHost:          "0.0.0.0",
+	HttpPort:          "9000",
+	RunMode:           "debug",
+	HTTPChallengePort: "9180",
+	Database:          "database",
+	StartCmd:          "login",
+	Demo:              false,
+	PageSize:          10,
+	CADir:             "",
+	GithubProxy:       "",
+}

+ 4 - 70
settings/settings.go

@@ -15,79 +15,13 @@ var (
 	LastModified string
 )
 
-type Server struct {
-	HttpHost            string `json:"http_host"`
-	HttpPort            string `json:"http_port"`
-	RunMode             string `json:"run_mode"`
-	JwtSecret           string `json:"jwt_secret"`
-	NodeSecret          string `json:"node_secret"`
-	HTTPChallengePort   string `json:"http_challenge_port"`
-	Email               string `json:"email"`
-	Database            string `json:"database"`
-	StartCmd            string `json:"start_cmd"`
-	CADir               string `json:"ca_dir"`
-	Demo                bool   `json:"demo"`
-	PageSize            int    `json:"page_size"`
-	GithubProxy         string `json:"github_proxy"`
-	CasdoorEndpoint     string `json:"casdoor_endpoint"`
-	CasdoorClientId     string `json:"casdoor_client_id"`
-	CasdoorClientSecret string `json:"casdoor_client_secret"`
-	CasdoorCertificate  string `json:"casdoor_certificate"`
-	CasdoorOrganization string `json:"casdoor_organization"`
-	CasdoorApplication  string `json:"casdoor_application"`
-	CasdoorRedirectUri  string `json:"casdoor_redirect_uri"`
-}
-
-type Nginx struct {
-	AccessLogPath string `json:"access_log_path"`
-	ErrorLogPath  string `json:"error_log_path"`
-	ConfigDir     string `json:"config_dir"`
-	PIDPath       string `json:"pid_path"`
-	TestConfigCmd string `json:"test_config_cmd"`
-	ReloadCmd     string `json:"reload_cmd"`
-	RestartCmd    string `json:"restart_cmd"`
-}
-
-type OpenAI struct {
-	BaseUrl string `json:"base_url"`
-	Token   string `json:"token"`
-	Proxy   string `json:"proxy"`
-	Model   string `json:"model"`
-}
-
-var ServerSettings = Server{
-	HttpHost:            "0.0.0.0",
-	HttpPort:            "9000",
-	RunMode:             "debug",
-	HTTPChallengePort:   "9180",
-	Database:            "database",
-	StartCmd:            "login",
-	Demo:                false,
-	PageSize:            10,
-	CADir:               "",
-	GithubProxy:         "",
-	CasdoorEndpoint:     "",
-	CasdoorClientId:     "",
-	CasdoorClientSecret: "",
-	CasdoorCertificate:  "",
-	CasdoorOrganization: "",
-	CasdoorApplication:  "",
-	CasdoorRedirectUri:  "",
-}
-
-var NginxSettings = Nginx{
-	AccessLogPath: "",
-	ErrorLogPath:  "",
-}
-
-var OpenAISettings = OpenAI{}
-
 var ConfPath string
 
 var sections = map[string]interface{}{
-	"server": &ServerSettings,
-	"nginx":  &NginxSettings,
-	"openai": &OpenAISettings,
+	"server":  &ServerSettings,
+	"nginx":   &NginxSettings,
+	"openai":  &OpenAISettings,
+	"casdoor": &CasdoorSettings,
 }
 
 func init() {

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません