summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-03-03 08:54:33 +0800
committerGitHub <noreply@github.com>2024-03-03 08:54:33 +0800
commit5ca2971ccbc8769f7e6ee41c125db47f818e7599 (patch)
tree3eb1648e6719795081bbd9fde9216a9760533b22 /modules/setting
parent63ec6faceae7bf3acfa533d167aa46f2c9b6befb (diff)
downloadgitea-5ca2971ccbc8769f7e6ee41c125db47f818e7599.tar.gz
gitea-5ca2971ccbc8769f7e6ee41c125db47f818e7599.zip
Fix incorrect cookie path for AppSubURL (#29534) (#29552)
Backport #29534 Regression of #24107 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/session.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/setting/session.go b/modules/setting/session.go
index 664c66f869..e9637fdfc5 100644
--- a/modules/setting/session.go
+++ b/modules/setting/session.go
@@ -21,7 +21,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) {
SessionConfig.ProviderConfig = path.Join(AppWorkPath, 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)