[MM-25780] Fix incorrect session length when logging in through mobile using SSO (#14874)
* Pass device ID * dont use device id as way of detecting * fix spelling mistake * update layers * fix test * fix linting * save schema * put columns in correct place * fix linting * update * upgrade go change * use props * fix stuff * update session tests * address PR comments * address PR comments
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
df943fbf91
Коммит
4c50c7c59b
11
web/oauth.go
11
web/oauth.go
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/app"
|
||||
@@ -301,7 +302,11 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
} else if action == model.OAUTH_ACTION_SSO_TO_EMAIL {
|
||||
redirectUrl = app.GetProtocol(r) + "://" + r.Host + "/claim?email=" + url.QueryEscape(props["email"])
|
||||
} else {
|
||||
err = c.App.DoLogin(w, r, user, "")
|
||||
isMobile, parseErr := strconv.ParseBool(props[model.USER_AUTH_SERVICE_IS_MOBILE])
|
||||
if parseErr != nil {
|
||||
mlog.Error("Error parsing boolean property from props", mlog.Err(parseErr))
|
||||
}
|
||||
err = c.App.DoLogin(w, r, user, "", isMobile, true, false)
|
||||
if err != nil {
|
||||
err.Translate(c.App.T)
|
||||
c.Err = err
|
||||
@@ -343,7 +348,7 @@ func loginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint)
|
||||
authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_LOGIN, redirectTo, loginHint, false)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -364,7 +369,7 @@ func mobileLoginWithOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", "")
|
||||
authUrl, err := c.App.GetOAuthLoginEndpoint(w, r, c.Params.Service, teamId, model.OAUTH_ACTION_MOBILE, "", "", true)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
|
||||
10
web/saml.go
10
web/saml.go
@@ -6,6 +6,7 @@ package web
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/audit"
|
||||
@@ -32,6 +33,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
action := r.URL.Query().Get("action")
|
||||
isMobile := action == model.OAUTH_ACTION_MOBILE
|
||||
redirectTo := r.URL.Query().Get("redirect_to")
|
||||
relayProps := map[string]string{}
|
||||
relayState := ""
|
||||
@@ -48,6 +50,8 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
relayProps["redirect_to"] = redirectTo
|
||||
}
|
||||
|
||||
relayProps[model.USER_AUTH_SERVICE_IS_MOBILE] = strconv.FormatBool(isMobile)
|
||||
|
||||
if len(relayProps) > 0 {
|
||||
relayState = b64.StdEncoding.EncodeToString([]byte(model.MapToJson(relayProps)))
|
||||
}
|
||||
@@ -142,7 +146,11 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddMeta("obtained_user_id", user.Id)
|
||||
c.LogAuditWithUserId(user.Id, "obtained user")
|
||||
|
||||
err = c.App.DoLogin(w, r, user, "")
|
||||
isMobile, parseErr := strconv.ParseBool(relayProps[model.USER_AUTH_SERVICE_IS_MOBILE])
|
||||
if parseErr != nil {
|
||||
mlog.Error("Error parsing boolean property from relay props", mlog.Err(parseErr))
|
||||
}
|
||||
err = c.App.DoLogin(w, r, user, "", isMobile, false, true)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
|
||||
Ссылка в новой задаче
Block a user