From 626f169e812285e4b6d2d5a094c60e4689970651 Mon Sep 17 00:00:00 2001 From: lanyulei Date: Mon, 18 Nov 2024 23:28:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20jwt=20=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/jwtauth/jwtauth.go | 6 +++--- tools/config/application.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/jwtauth/jwtauth.go b/pkg/jwtauth/jwtauth.go index 175e5e42..1bfc3428 100644 --- a/pkg/jwtauth/jwtauth.go +++ b/pkg/jwtauth/jwtauth.go @@ -4,8 +4,8 @@ import ( "crypto/rsa" "errors" config2 "ferry/tools/config" - "io/ioutil" "net/http" + "os" "strings" "time" @@ -234,7 +234,7 @@ func (mw *GinJWTMiddleware) readKeys() error { } func (mw *GinJWTMiddleware) privateKey() error { - keyData, err := ioutil.ReadFile(mw.PrivKeyFile) + keyData, err := os.ReadFile(mw.PrivKeyFile) if err != nil { return ErrNoPrivKeyFile } @@ -247,7 +247,7 @@ func (mw *GinJWTMiddleware) privateKey() error { } func (mw *GinJWTMiddleware) publicKey() error { - keyData, err := ioutil.ReadFile(mw.PubKeyFile) + keyData, err := os.ReadFile(mw.PubKeyFile) if err != nil { return ErrNoPubKeyFile } diff --git a/tools/config/application.go b/tools/config/application.go index cd306856..945446e5 100644 --- a/tools/config/application.go +++ b/tools/config/application.go @@ -22,7 +22,7 @@ func InitApplication(cfg *viper.Viper) *Application { Host: cfg.GetString("host"), Port: portDefault(cfg), Name: cfg.GetString("name"), - JwtSecret: cfg.GetString("jwtSecret"), + JwtSecret: viper.GetString("settings.jwt.secret"), Mode: cfg.GetString("mode"), DemoMsg: cfg.GetString("demoMsg"), Domain: cfg.GetString("domain"), @@ -41,7 +41,7 @@ func portDefault(cfg *viper.Viper) string { } func isHttpsDefault(cfg *viper.Viper) bool { - if cfg.GetString("ishttps") == "" || cfg.GetBool("ishttps") == false{ + if cfg.GetString("ishttps") == "" || cfg.GetBool("ishttps") == false { return false } else { return true