MM-41211: Adds ability to set SessionLengthSSOInDays to a decimal. (#19396)

* MM-41211: Accepts a decimal for the SSO session length.

* MM-41211: Fixes test and logic error.

* MM-41211: Validates session length is minimum 1 hour.

* MM-41211: Tricking the CI to allow an empty string.

* Fixes a test error and some lint changes.

* Fix error.

* Reverting IDE change.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
mkraft
2022-02-14 12:06:47 -05:00
коммит произвёл GitHub
родитель 10c8c84704
Коммит 7398451030
15 изменённых файлов: 76 добавлений и 54 удалений

Просмотреть файл

@@ -239,7 +239,7 @@ func (a *App) UpdateLastActivityAtIfNeeded(session model.Session) {
a.UpdateWebConnUserActivity(session, now)
if now-session.LastActivityAt < model.SessionActivityTimeout {
if now-session.LastActivityAt < model.SessionActivityTimeoutMiliseconds {
return
}
@@ -321,22 +321,22 @@ func (a *App) GetSessionLengthInMillis(session *model.Session) int64 {
return 0
}
var days int
var hours int
if session.IsMobileApp() {
days = *a.Config().ServiceSettings.SessionLengthMobileInDays
hours = *a.Config().ServiceSettings.SessionLengthMobileInHours()
} else if session.IsSSOLogin() {
days = *a.Config().ServiceSettings.SessionLengthSSOInDays
hours = *a.Config().ServiceSettings.SessionLengthSSOInHours()
} else {
days = *a.Config().ServiceSettings.SessionLengthWebInDays
hours = *a.Config().ServiceSettings.SessionLengthWebInHours()
}
return int64(days * 24 * 60 * 60 * 1000)
return int64(hours * 60 * 60 * 1000)
}
// SetSessionExpireInDays sets the session's expiry the specified number of days
// SetSessionExpireInHours sets the session's expiry the specified number of days
// relative to either the session creation date or the current time, depending
// on the `ExtendSessionOnActivity` config setting.
func (a *App) SetSessionExpireInDays(session *model.Session, days int) {
a.ch.srv.userService.SetSessionExpireInDays(session, days)
func (a *App) SetSessionExpireInHours(session *model.Session, hours int) {
a.ch.srv.userService.SetSessionExpireInHours(session, hours)
}
func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAccessToken, *model.AppError) {
@@ -425,7 +425,7 @@ func (a *App) createSessionForUserAccessToken(tokenString string) (*model.Sessio
} else {
session.AddProp(model.SessionPropIsGuest, "false")
}
a.ch.srv.userService.SetSessionExpireInDays(session, model.SessionUserAccessTokenExpiry)
a.ch.srv.userService.SetSessionExpireInHours(session, model.SessionUserAccessTokenExpiryHours)
session, nErr = a.Srv().Store.Session().Save(session)
if nErr != nil {