From 1902a59ebdc6847c6215c7ad9df14e9579a373a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Tue, 10 Dec 2024 00:46:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AFhash=E4=BD=BF=E7=94=A8sha256=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/http/middleware/must_login.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/http/middleware/must_login.go b/internal/http/middleware/must_login.go index 1efa0b99c9..473ab21cbf 100644 --- a/internal/http/middleware/must_login.go +++ b/internal/http/middleware/must_login.go @@ -2,6 +2,7 @@ package middleware import ( "context" + "crypto/sha256" "fmt" "net" "net/http" @@ -10,7 +11,6 @@ import ( "github.com/go-rat/chix" "github.com/spf13/cast" - "golang.org/x/crypto/sha3" "github.com/TheTNB/panel/internal/app" ) @@ -65,7 +65,7 @@ func MustLogin(next http.Handler) http.Handler { if safeLogin { safeClientHash := cast.ToString(sess.Get("safe_client")) ip, _, _ := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr)) - clientHash := fmt.Sprintf("%x", sha3.Sum256([]byte(ip))) + clientHash := fmt.Sprintf("%x", sha256.Sum256([]byte(ip))) if safeClientHash != clientHash || safeClientHash == "" { render := chix.NewRender(w) render.Status(http.StatusUnauthorized)