[MM-39583] - Intermediary web login page: Workspace Cookies (#19256)
* [MM-39583] - Intermediary web login page: Workspace Cookies * only cloud * fix error with license check * feedback impl * improvement * make improvements Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8ad9a22e77
Коммит
664af506a3
@@ -391,6 +391,7 @@ type AppIface interface {
|
||||
AllowOAuthAppAccessToUser(userID string, authRequest *model.AuthorizeRequest) (string, *model.AppError)
|
||||
AppendFile(fr io.Reader, path string) (int64, *model.AppError)
|
||||
AsymmetricSigningKey() *ecdsa.PrivateKey
|
||||
AttachCloudSessionCookie(c *request.Context, w http.ResponseWriter, r *http.Request)
|
||||
AttachDeviceId(sessionID string, deviceID string, expiresAt int64) *model.AppError
|
||||
AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request)
|
||||
AuthenticateUserForLogin(c *request.Context, id, loginId, password, mfaToken, cwsToken string, ldapOnly bool) (user *model.User, err *model.AppError)
|
||||
|
||||
33
app/login.go
33
app/login.go
@@ -238,6 +238,39 @@ func (a *App) DoLogin(c *request.Context, w http.ResponseWriter, r *http.Request
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) AttachCloudSessionCookie(c *request.Context, w http.ResponseWriter, r *http.Request) {
|
||||
secure := false
|
||||
if GetProtocol(r) == "https" {
|
||||
secure = true
|
||||
}
|
||||
|
||||
maxAge := *a.Config().ServiceSettings.SessionLengthWebInDays * 60 * 60 * 24
|
||||
domain := a.GetCookieDomain()
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
expiresAt := time.Unix(model.GetMillis()/1000+int64(maxAge), 0)
|
||||
|
||||
var val string
|
||||
if strings.Contains(domain, "localhost") {
|
||||
val = "localhost"
|
||||
} else {
|
||||
val = strings.SplitN(domain, ".", 2)[0]
|
||||
domain = strings.SplitN(domain, ".", 3)[2]
|
||||
}
|
||||
|
||||
cookie := &http.Cookie{
|
||||
Name: model.SessionCookieCloudUrl,
|
||||
Value: val,
|
||||
Path: subpath,
|
||||
MaxAge: maxAge,
|
||||
Expires: expiresAt,
|
||||
HttpOnly: true,
|
||||
Domain: domain,
|
||||
Secure: secure,
|
||||
}
|
||||
|
||||
http.SetCookie(w, cookie)
|
||||
}
|
||||
|
||||
func (a *App) AttachSessionCookies(c *request.Context, w http.ResponseWriter, r *http.Request) {
|
||||
secure := false
|
||||
if GetProtocol(r) == "https" {
|
||||
|
||||
@@ -686,6 +686,21 @@ func (a *OpenTracingAppLayer) AsymmetricSigningKey() *ecdsa.PrivateKey {
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AttachCloudSessionCookie(c *request.Context, w http.ResponseWriter, r *http.Request) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AttachCloudSessionCookie")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store.SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
a.app.AttachCloudSessionCookie(c, w, r)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AttachDeviceId(sessionID string, deviceID string, expiresAt int64) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AttachDeviceId")
|
||||
|
||||
Ссылка в новой задаче
Block a user