Improving default session timeout behavour. (#10453)
* Improving default session timeout behavour. * Changing mind to 180 days instead of 548 days
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9abd4dd7dc
Коммит
5dae08761c
@@ -76,14 +76,13 @@ func (a *App) GetSession(token string) (*model.Session, *model.AppError) {
|
||||
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token}, "", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
license := a.License()
|
||||
if *a.Config().ServiceSettings.SessionIdleTimeoutInMinutes > 0 &&
|
||||
license != nil && *license.Features.Compliance &&
|
||||
session != nil && !session.IsOAuth && !session.IsMobileApp() &&
|
||||
if session != nil &&
|
||||
*a.Config().ServiceSettings.SessionIdleTimeoutInMinutes > 0 &&
|
||||
!session.IsOAuth &&
|
||||
session.Props[model.SESSION_PROP_TYPE] != model.SESSION_TYPE_USER_ACCESS_TOKEN {
|
||||
|
||||
timeout := int64(*a.Config().ServiceSettings.SessionIdleTimeoutInMinutes) * 1000 * 60
|
||||
if model.GetMillis()-session.LastActivityAt > timeout {
|
||||
if (model.GetMillis() - session.LastActivityAt) > timeout {
|
||||
a.RevokeSessionById(session.Id)
|
||||
return nil, model.NewAppError("GetSession", "api.context.invalid_token.error", map[string]interface{}{"Token": token}, "idle timeout", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
@@ -65,20 +65,6 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
|
||||
assert.Equal(t, "idle timeout", err.DetailedError)
|
||||
assert.Nil(t, rsession)
|
||||
|
||||
// Test mobile session, should not timeout
|
||||
session = &model.Session{
|
||||
UserId: model.NewId(),
|
||||
DeviceId: "android:" + model.NewId(),
|
||||
}
|
||||
|
||||
session, _ = th.App.CreateSession(session)
|
||||
time = session.LastActivityAt - (1000 * 60 * 6)
|
||||
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
|
||||
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
|
||||
|
||||
_, err = th.App.GetSession(session.Token)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Test oauth session, should not timeout
|
||||
session = &model.Session{
|
||||
UserId: model.NewId(),
|
||||
@@ -107,21 +93,6 @@ func TestGetSessionIdleTimeoutInMinutes(t *testing.T) {
|
||||
_, err = th.App.GetSession(session.Token)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Test regular session with license off, should not timeout
|
||||
th.App.SetLicense(nil)
|
||||
|
||||
session = &model.Session{
|
||||
UserId: model.NewId(),
|
||||
}
|
||||
|
||||
session, _ = th.App.CreateSession(session)
|
||||
time = session.LastActivityAt - (1000 * 60 * 6)
|
||||
<-th.App.Srv.Store.Session().UpdateLastActivityAt(session.Id, time)
|
||||
th.App.ClearSessionCacheForUserSkipClusterSend(session.UserId)
|
||||
|
||||
_, err = th.App.GetSession(session.Token)
|
||||
assert.Nil(t, err)
|
||||
|
||||
th.App.SetLicense(model.NewTestLicense("compliance"))
|
||||
|
||||
// Test regular session with timeout set to 0, should not timeout
|
||||
|
||||
Ссылка в новой задаче
Block a user