mirror of https://github.com/gogs/gogs.git
cookie: enhance cookie security (#3525)
parent
279e475b89
commit
4c5255f5ad
|
@ -154,6 +154,7 @@ SECRET_KEY = !#@FDEWREWR&*(
|
|||
LOGIN_REMEMBER_DAYS = 7
|
||||
COOKIE_USERNAME = gogs_awesome
|
||||
COOKIE_REMEMBER_NAME = gogs_incredible
|
||||
COOKIE_SECURE = false
|
||||
; Reverse proxy authentication header name of user name
|
||||
REVERSE_PROXY_AUTHENTICATION_USER = X-WEBAUTH-USER
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -98,6 +98,7 @@ var (
|
|||
LogInRememberDays int
|
||||
CookieUserName string
|
||||
CookieRememberName string
|
||||
CookieSecure bool
|
||||
ReverseProxyAuthUser string
|
||||
|
||||
// Database settings
|
||||
|
@ -466,6 +467,7 @@ func NewContext() {
|
|||
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt()
|
||||
CookieUserName = sec.Key("COOKIE_USERNAME").String()
|
||||
CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").String()
|
||||
CookieSecure = sec.Key("COOKIE_SECURE").MustBool(false)
|
||||
ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
|
||||
|
||||
sec = Cfg.Section("attachment")
|
||||
|
|
|
@ -123,8 +123,8 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
|
|||
|
||||
if form.Remember {
|
||||
days := 86400 * setting.LogInRememberDays
|
||||
ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl)
|
||||
ctx.SetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName, u.Name, days, setting.AppSubUrl)
|
||||
ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl, "", setting.CookieSecure, true)
|
||||
ctx.SetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName, u.Name, days, setting.AppSubUrl, "", setting.CookieSecure, true)
|
||||
}
|
||||
|
||||
ctx.Session.Set("uid", u.ID)
|
||||
|
|
Loading…
Reference in New Issue