From bd4314e977b883c1bffe4f593e187a1c62abbfec Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 5 Jan 2016 11:13:25 -0600 Subject: PLT-1558 adding session length to config file --- model/config.go | 24 ++++++++++++++++++++++++ model/session.go | 28 ++++++++++++++-------------- 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'model') diff --git a/model/config.go b/model/config.go index a4792ff9e..ed56ed0c7 100644 --- a/model/config.go +++ b/model/config.go @@ -36,6 +36,10 @@ type ServiceSettings struct { EnableTesting bool EnableDeveloper *bool EnableSecurityFixAlert *bool + SessionLengthWebInDays *int + SessionLengthMobileInDays *int + SessionLengthSSOInDays *int + SessionCacheInMinutes *int } type SSOSettings struct { @@ -306,6 +310,26 @@ func (o *Config) SetDefaults() { o.LdapSettings.Enable = new(bool) *o.LdapSettings.Enable = false } + + if o.ServiceSettings.SessionLengthWebInDays == nil { + o.ServiceSettings.SessionLengthWebInDays = new(int) + *o.ServiceSettings.SessionLengthWebInDays = 30 + } + + if o.ServiceSettings.SessionLengthMobileInDays == nil { + o.ServiceSettings.SessionLengthMobileInDays = new(int) + *o.ServiceSettings.SessionLengthMobileInDays = 30 + } + + if o.ServiceSettings.SessionLengthSSOInDays == nil { + o.ServiceSettings.SessionLengthSSOInDays = new(int) + *o.ServiceSettings.SessionLengthSSOInDays = 30 + } + + if o.ServiceSettings.SessionCacheInMinutes == nil { + o.ServiceSettings.SessionCacheInMinutes = new(int) + *o.ServiceSettings.SessionCacheInMinutes = 10 + } } func (o *Config) IsValid() *AppError { diff --git a/model/session.go b/model/session.go index 5fe74a161..d1dfc3514 100644 --- a/model/session.go +++ b/model/session.go @@ -9,18 +9,18 @@ import ( ) const ( - SESSION_COOKIE_TOKEN = "MMTOKEN" - SESSION_TIME_WEB_IN_DAYS = 30 - SESSION_TIME_WEB_IN_SECS = 60 * 60 * 24 * SESSION_TIME_WEB_IN_DAYS - SESSION_TIME_MOBILE_IN_DAYS = 30 - SESSION_TIME_MOBILE_IN_SECS = 60 * 60 * 24 * SESSION_TIME_MOBILE_IN_DAYS - SESSION_TIME_OAUTH_IN_DAYS = 365 - SESSION_TIME_OAUTH_IN_SECS = 60 * 60 * 24 * SESSION_TIME_OAUTH_IN_DAYS - SESSION_CACHE_IN_SECS = 60 * 10 - SESSION_CACHE_SIZE = 10000 - SESSION_PROP_PLATFORM = "platform" - SESSION_PROP_OS = "os" - SESSION_PROP_BROWSER = "browser" + SESSION_COOKIE_TOKEN = "MMTOKEN" + // SESSION_TIME_WEB_IN_DAYS = 30 + // SESSION_TIME_WEB_IN_SECS = 60 * 60 * 24 * SESSION_TIME_WEB_IN_DAYS + // SESSION_TIME_MOBILE_IN_DAYS = 30 + // SESSION_TIME_MOBILE_IN_SECS = 60 * 60 * 24 * SESSION_TIME_MOBILE_IN_DAYS + // SESSION_TIME_OAUTH_IN_DAYS = 365 + // SESSION_TIME_OAUTH_IN_SECS = 60 * 60 * 24 * SESSION_TIME_OAUTH_IN_DAYS + // SESSION_CACHE_IN_SECS = 60 * 10 + SESSION_CACHE_SIZE = 10000 + SESSION_PROP_PLATFORM = "platform" + SESSION_PROP_OS = "os" + SESSION_PROP_BROWSER = "browser" ) type Session struct { @@ -89,8 +89,8 @@ func (me *Session) IsExpired() bool { return false } -func (me *Session) SetExpireInDays(days int64) { - me.ExpiresAt = GetMillis() + (1000 * 60 * 60 * 24 * days) +func (me *Session) SetExpireInDays(days int) { + me.ExpiresAt = GetMillis() + (1000 * 60 * 60 * 24 * int64(days)) } func (me *Session) AddProp(key string, value string) { -- cgit v1.2.3-1-g7c22 From 214c6bc15ed1d0c9f94d0f0545d3f95241893cdc Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 5 Jan 2016 11:46:51 -0600 Subject: Adding UI for session length settings --- model/session.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'model') diff --git a/model/session.go b/model/session.go index d1dfc3514..5d9424d64 100644 --- a/model/session.go +++ b/model/session.go @@ -9,14 +9,7 @@ import ( ) const ( - SESSION_COOKIE_TOKEN = "MMTOKEN" - // SESSION_TIME_WEB_IN_DAYS = 30 - // SESSION_TIME_WEB_IN_SECS = 60 * 60 * 24 * SESSION_TIME_WEB_IN_DAYS - // SESSION_TIME_MOBILE_IN_DAYS = 30 - // SESSION_TIME_MOBILE_IN_SECS = 60 * 60 * 24 * SESSION_TIME_MOBILE_IN_DAYS - // SESSION_TIME_OAUTH_IN_DAYS = 365 - // SESSION_TIME_OAUTH_IN_SECS = 60 * 60 * 24 * SESSION_TIME_OAUTH_IN_DAYS - // SESSION_CACHE_IN_SECS = 60 * 10 + SESSION_COOKIE_TOKEN = "MMTOKEN" SESSION_CACHE_SIZE = 10000 SESSION_PROP_PLATFORM = "platform" SESSION_PROP_OS = "os" -- cgit v1.2.3-1-g7c22