aboutsummaryrefslogtreecommitdiff
path: root/internal/conf
diff options
context:
space:
mode:
Diffstat (limited to 'internal/conf')
-rw-r--r--internal/conf/conf.go28
-rw-r--r--internal/conf/static.go25
2 files changed, 33 insertions, 20 deletions
diff --git a/internal/conf/conf.go b/internal/conf/conf.go
index 2672b0a7..46133ab8 100644
--- a/internal/conf/conf.go
+++ b/internal/conf/conf.go
@@ -17,7 +17,6 @@ import (
_ "github.com/go-macaron/cache/memcache"
_ "github.com/go-macaron/cache/redis"
- "github.com/go-macaron/session"
_ "github.com/go-macaron/session/redis"
"github.com/mcuadros/go-version"
"github.com/pkg/errors"
@@ -254,6 +253,14 @@ func Init(customConf string) error {
return errors.Wrap(err, "mapping [user] section")
}
+ // ***********************************
+ // ----- Session settings -----
+ // ***********************************
+
+ if err = File.Section("session").MapTo(&Session); err != nil {
+ return errors.Wrap(err, "mapping [session] section")
+ }
+
handleDeprecated()
// TODO
@@ -460,10 +467,6 @@ var (
CacheInterval int
CacheConn string
- // Session settings
- SessionConfig session.Options
- CSRFCookieName string
-
// Cron tasks
Cron struct {
UpdateMirror struct {
@@ -696,23 +699,8 @@ func newCacheService() {
log.Trace("Cache service is enabled")
}
-func newSessionService() {
- SessionConfig.Provider = File.Section("session").Key("PROVIDER").In("memory",
- []string{"memory", "file", "redis", "mysql"})
- SessionConfig.ProviderConfig = strings.Trim(File.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
- SessionConfig.CookieName = File.Section("session").Key("COOKIE_NAME").MustString("i_like_gogs")
- SessionConfig.CookiePath = Server.Subpath
- SessionConfig.Secure = File.Section("session").Key("COOKIE_SECURE").MustBool()
- SessionConfig.Gclifetime = File.Section("session").Key("GC_INTERVAL_TIME").MustInt64(3600)
- SessionConfig.Maxlifetime = File.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
- CSRFCookieName = File.Section("session").Key("CSRF_COOKIE_NAME").MustString("_csrf")
-
- log.Trace("Session service is enabled")
-}
-
func NewServices() {
newCacheService()
- newSessionService()
}
// HookMode indicates whether program starts as Git server-side hook callback.
diff --git a/internal/conf/static.go b/internal/conf/static.go
index 6e37ba06..641feec0 100644
--- a/internal/conf/static.go
+++ b/internal/conf/static.go
@@ -211,6 +211,22 @@ var (
User struct {
EnableEmailNotification bool
}
+
+ // Session settings
+ Session struct {
+ Provider string
+ ProviderConfig string
+ CookieName string
+ CookieSecure bool
+ GCInterval int64 `ini:"GC_INTERVAL"`
+ MaxLifeTime int64
+ CSRFCookieName string `ini:"CSRF_COOKIE_NAME"`
+
+ // Deprecated: Use GCInterval instead, will be removed in 0.13.
+ GCIntervalTime int64 `ini:"GC_INTERVAL_TIME"`
+ // Deprecated: Use MaxLifeTime instead, will be removed in 0.13.
+ SessionLifeTime int64
+ }
)
// handleDeprecated transfers deprecated values to the new ones when set.
@@ -268,4 +284,13 @@ func handleDeprecated() {
User.EnableEmailNotification = true
Auth.EnableNotifyMail = false
}
+
+ if Session.GCIntervalTime > 0 {
+ Session.GCInterval = Session.GCIntervalTime
+ Session.GCIntervalTime = 0
+ }
+ if Session.SessionLifeTime > 0 {
+ Session.MaxLifeTime = Session.SessionLifeTime
+ Session.SessionLifeTime = 0
+ }
}