security: P1 Cookie Secure标志 + P0 Go补丁升级脚本 + 第三轮审计报告

- P1: auth.go 8处Cookie补充Secure:true+SameSite,gosec 84→78
- P0: 新增go-upgrade.sh (check/upgrade/status三模式)
- docs: 安全审计报告第十一章 - SAST/CVE/CWE审计结果
This commit is contained in:
selfrelease
2026-06-26 15:53:05 +08:00
parent 728d1c8dd5
commit 60b4c3244e
3 changed files with 348 additions and 1 deletions
+8
View File
@@ -100,6 +100,7 @@ func (h *AuthHandler) Register(w http.ResponseWriter, r *http.Request) {
Value: tokenPair.AccessToken,
Path: "/",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: int(24 * time.Hour / time.Second),
})
@@ -183,6 +184,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
Value: tokenPair.AccessToken,
Path: "/",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: int(24 * time.Hour / time.Second),
})
@@ -191,6 +193,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
Value: tokenPair.RefreshToken,
Path: "/api/v1/auth/refresh",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: int(7 * 24 * time.Hour / time.Second),
})
@@ -216,6 +219,8 @@ func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request) {
Value: "",
Path: "/",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: -1,
})
http.SetCookie(w, &http.Cookie{
@@ -223,6 +228,8 @@ func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request) {
Value: "",
Path: "/api/v1/auth/refresh",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: -1,
})
response.JSON(w, http.StatusOK, nil)
@@ -406,6 +413,7 @@ func (h *AuthHandler) Refresh(w http.ResponseWriter, r *http.Request) {
Value: tokenPair.AccessToken,
Path: "/",
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
MaxAge: int(24 * time.Hour / time.Second),
})