mirror of https://github.com/gogs/gogs.git
csrf: set cookie HttpOnly and Secure (#6013)
parent
5800d78b99
commit
14cd16f1f8
|
@ -153,11 +153,14 @@ func newMacaron() *macaron.Macaron {
|
||||||
Secure: conf.Session.CookieSecure,
|
Secure: conf.Session.CookieSecure,
|
||||||
}))
|
}))
|
||||||
m.Use(csrf.Csrfer(csrf.Options{
|
m.Use(csrf.Csrfer(csrf.Options{
|
||||||
Secret: conf.Security.SecretKey,
|
Secret: conf.Security.SecretKey,
|
||||||
Cookie: conf.Session.CSRFCookieName,
|
Header: "X-Csrf-Token",
|
||||||
SetCookie: true,
|
Cookie: conf.Session.CSRFCookieName,
|
||||||
Header: "X-Csrf-Token",
|
CookieDomain: conf.Server.URL.Hostname(),
|
||||||
CookiePath: conf.Server.Subpath,
|
CookiePath: conf.Server.Subpath,
|
||||||
|
CookieHttpOnly: true,
|
||||||
|
SetCookie: true,
|
||||||
|
Secure: conf.Server.URL.Scheme == "https",
|
||||||
}))
|
}))
|
||||||
m.Use(toolbox.Toolboxer(m, toolbox.Options{
|
m.Use(toolbox.Toolboxer(m, toolbox.Options{
|
||||||
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
|
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
|
||||||
|
@ -412,9 +415,7 @@ func runWeb(c *cli.Context) error {
|
||||||
Post(bindIgnErr(form.UpdateOrgSetting{}), org.SettingsPost)
|
Post(bindIgnErr(form.UpdateOrgSetting{}), org.SettingsPost)
|
||||||
m.Post("/avatar", binding.MultipartForm(form.Avatar{}), org.SettingsAvatar)
|
m.Post("/avatar", binding.MultipartForm(form.Avatar{}), org.SettingsAvatar)
|
||||||
m.Post("/avatar/delete", org.SettingsDeleteAvatar)
|
m.Post("/avatar/delete", org.SettingsDeleteAvatar)
|
||||||
|
|
||||||
m.Group("/hooks", webhookRoutes)
|
m.Group("/hooks", webhookRoutes)
|
||||||
|
|
||||||
m.Route("/delete", "GET,POST", org.SettingsDelete)
|
m.Route("/delete", "GET,POST", org.SettingsDelete)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue