diff --git a/data/config.example.json b/data/config.example.json index 03e3a8c..ee0d5b1 100644 --- a/data/config.example.json +++ b/data/config.example.json @@ -13,7 +13,8 @@ }, "server_config": { "port": 8080, - "base_url": "https://profile.example.com" + "base_url": "https://profile.example.com", + "session_store": "redis" }, "email_config": { "username": "noreply", diff --git a/src/main/config.go b/src/main/config.go index 6c03db5..2c3cf6b 100644 --- a/src/main/config.go +++ b/src/main/config.go @@ -22,8 +22,9 @@ type StyleConfig struct { } type WebserverConfig struct { - Port int `json:"port"` - BaseURL string `json:"base_url"` + Port int `json:"port"` + BaseURL string `json:"base_url"` + SessionStore string `json:"session_store"` } type EmailConfig struct { diff --git a/src/main/main.go b/src/main/main.go index 0b05d8a..19a02ee 100644 --- a/src/main/main.go +++ b/src/main/main.go @@ -221,8 +221,6 @@ func changePasswordHandler(w http.ResponseWriter, r *http.Request) { func main() { logging.Info("Starting the server") - sessionManager = session.GetSessionManager() - sessionManager.SetStoreType(session.Redis) var err error serverConfig, err = loadServerConfig("./data/config.json") @@ -230,6 +228,16 @@ func main() { log.Fatal("Could not load server config") } + sessionManager = session.GetSessionManager() + if serverConfig.WebserverConfig.SessionStore == "in_memory" { + sessionManager.SetStoreType(session.InMemory) + } else if serverConfig.WebserverConfig.SessionStore == "redis" { + sessionManager.SetStoreType(session.Redis) + } else { + logging.Warnf("'%s' is an unknown session store type defaulting to in memory", serverConfig.WebserverConfig.SessionStore) + sessionManager.SetStoreType(session.InMemory) + } + noReplyEmail = email.CreateEmailAccount(email.EmailAccountData{ Username: serverConfig.EmailConfig.Username, Password: serverConfig.EmailConfig.Password,