feat: 准备 Admin 线上 HTTPS 部署 (#81)
This commit is contained in:
@@ -42,8 +42,11 @@ func CSRFMiddleware() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
// HttpOnly 必须为 false —— 双提交方案要让页面把值填进表单。
|
||||
// 本项目只监听本机,Secure 先留 false,将来上 HTTPS 再打开。
|
||||
c.SetCookie(csrfCookieName, token, 12*3600, "/", "", false, false)
|
||||
http.SetCookie(c.Writer, &http.Cookie{
|
||||
Name: csrfCookieName, Value: token, Path: "/", HttpOnly: false,
|
||||
Secure: requestIsHTTPS(c.Request), SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 12 * 3600,
|
||||
})
|
||||
}
|
||||
// 交给模板渲染成隐藏字段
|
||||
c.Set(csrfFieldName, token)
|
||||
|
||||
Reference in New Issue
Block a user