MM-55320 - Limit length of browser user agent version; ratelimit the /sessions endpoint (#25900)
* add ratelimit to /sessions; cap userAgent version length; tests * add MaxSessionsLimit; remove oldest session first; tests * can't use slices in 1.20; improve test * nits * add GetLRUSessions; move limiting to CreateSession; remove rate limiting * use queryBuilder * mysql needs a limit when using offset * update i18n * refactor into limitNumberOfSessions; protect createSessionForUserAccessToken * add comment to GetLRUSessions * add limit to oauth path; PR comments
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9a2d96073e
Коммит
17d11db395
@@ -383,6 +383,11 @@ func (a *App) GetOAuthAccessTokenForCodeFlow(c request.CTX, clientId, grantType,
|
||||
}
|
||||
|
||||
func (a *App) newSession(c request.CTX, app *model.OAuthApp, user *model.User) (*model.Session, *model.AppError) {
|
||||
if err := a.limitNumberOfSessions(c, user.Id); err != nil {
|
||||
return nil, model.NewAppError("newSession", "api.oauth.get_access_token.internal_session.app_error", nil,
|
||||
"", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
// Set new token an session
|
||||
session := &model.Session{UserId: user.Id, Roles: user.Roles, IsOAuth: true}
|
||||
session.GenerateCSRF()
|
||||
|
||||
Ссылка в новой задаче
Block a user