From d57d7b73b61e4f21e1272e840eab47713d535116 Mon Sep 17 00:00:00 2001 From: naiba Date: Sun, 1 Mar 2026 03:49:01 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20=E8=AE=BE=E7=BD=AECookie=20Secure?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=A2=9E=E5=BC=BA=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根据运行环境动态设置Secure属性 - 开发环境兼容HTTP,生产环境强制HTTPS - 解决CodeQL扫描发现的安全漏洞 Co-authored-by: naiba/CloudCode --- cmd/dashboard/controller/oauth2.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/dashboard/controller/oauth2.go b/cmd/dashboard/controller/oauth2.go index ebe7e50..2a418ad 100644 --- a/cmd/dashboard/controller/oauth2.go +++ b/cmd/dashboard/controller/oauth2.go @@ -65,8 +65,7 @@ func oauth2redirect(c *gin.Context) (*model.Oauth2LoginResponse, error) { RedirectURL: redirectURL, }, cache.DefaultExpiration) - url := o2conf.AuthCodeURL(state, oauth2.AccessTypeOnline) - c.SetCookie("nz-o2s", stateKey, 60*5, "", "", false, false) + c.SetCookie("nz-o2s", stateKey, 60*5, "", "", c.Request.URL.Scheme == "https" || c.Request.TLS != nil, false) return &model.Oauth2LoginResponse{Redirect: url}, nil }