diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-03-03 08:14:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-03 00:14:12 +0000 |
commit | 44398e405ffe297997c6b9c8dbb97f966926b65a (patch) | |
tree | 7a2fb5bb03bb66970b16c1656aa9141a2d407aae /modules/setting/session.go | |
parent | cc896258b9ea9f60c33077c937ce9b3951b58b35 (diff) | |
download | gitea-44398e405ffe297997c6b9c8dbb97f966926b65a.tar.gz gitea-44398e405ffe297997c6b9c8dbb97f966926b65a.zip |
Fix incorrect cookie path for AppSubURL (#29534)
Regression of #24107
Diffstat (limited to 'modules/setting/session.go')
-rw-r--r-- | modules/setting/session.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/setting/session.go b/modules/setting/session.go index 8b9b754b38..70497e5eaa 100644 --- a/modules/setting/session.go +++ b/modules/setting/session.go @@ -20,7 +20,7 @@ var SessionConfig = struct { ProviderConfig string // Cookie name to save session ID. Default is "MacaronSession". CookieName string - // Cookie path to store. Default is "/". HINT: there was a bug, the old value doesn't have trailing slash, and could be empty "". + // Cookie path to store. Default is "/". CookiePath string // GC interval time in seconds. Default is 3600. Gclifetime int64 @@ -49,7 +49,10 @@ func loadSessionFrom(rootCfg ConfigProvider) { fatalDuplicatedPath("session", SessionConfig.ProviderConfig) } SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea") - SessionConfig.CookiePath = AppSubURL + "/" // there was a bug, old code only set CookePath=AppSubURL, no trailing slash + SessionConfig.CookiePath = AppSubURL + if SessionConfig.CookiePath == "" { + SessionConfig.CookiePath = "/" + } SessionConfig.Secure = sec.Key("COOKIE_SECURE").MustBool(strings.HasPrefix(strings.ToLower(AppURL), "https://")) SessionConfig.Gclifetime = sec.Key("GC_INTERVAL_TIME").MustInt64(86400) SessionConfig.Maxlifetime = sec.Key("SESSION_LIFE_TIME").MustInt64(86400) |