diff options
author | zeripath <art27@cantab.net> | 2019-04-20 07:44:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-20 07:44:50 +0100 |
commit | b33f7f792bf3a1a1e54639db94cc80b84f68ebfd (patch) | |
tree | 663f30dbc39028c188f88a35c68910abdaaa1331 /modules/setting/session.go | |
parent | b74dc970e9911e42861b88a1338ca504644b7cd2 (diff) | |
download | gitea-b33f7f792bf3a1a1e54639db94cc80b84f68ebfd.tar.gz gitea-b33f7f792bf3a1a1e54639db94cc80b84f68ebfd.zip |
Prevent creating empty sessions (#6677)
* Prevent creating empty sessions
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update modules/setting/session.go
* Remove unnecessary option
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add destory to list of ignored misspellings
* rename cookie.go -> virtual.go
* Delete old file
* Add test to ensure that sessions are not created without being logged in
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix tests
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update integrations/create_no_session_test.go
Diffstat (limited to 'modules/setting/session.go')
-rw-r--r-- | modules/setting/session.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/setting/session.go b/modules/setting/session.go index 97ac50d861..313c3c76b5 100644 --- a/modules/setting/session.go +++ b/modules/setting/session.go @@ -5,11 +5,15 @@ package setting import ( + "encoding/json" "path" "path/filepath" "strings" "code.gitea.io/gitea/modules/log" + // This ensures that VirtualSessionProvider is available + _ "code.gitea.io/gitea/modules/session" + "github.com/go-macaron/session" ) @@ -31,5 +35,12 @@ func newSessionService() { SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400) SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400) + shadowConfig, err := json.Marshal(SessionConfig) + if err != nil { + log.Fatal("Can't shadow session config: %v", err) + } + SessionConfig.ProviderConfig = string(shadowConfig) + SessionConfig.Provider = "VirtualSession" + log.Info("Session Service Enabled") } |