You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

session.go 1.3 kB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "path"
  7. "path/filepath"
  8. "strings"
  9. "code.gitea.io/gitea/modules/log"
  10. "github.com/go-macaron/session"
  11. )
  12. var (
  13. // SessionConfig difines Session settings
  14. SessionConfig session.Options
  15. )
  16. func newSessionService() {
  17. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  18. []string{"memory", "file", "redis", "mysql", "postgres", "couchbase", "memcache", "nodb"})
  19. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ")
  20. if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
  21. SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig)
  22. }
  23. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
  24. SessionConfig.CookiePath = AppSubURL
  25. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
  26. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  27. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  28. log.Info("Session Service Enabled")
  29. }