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
Этот коммит содержится в:
Christopher Poile
2024-03-21 08:48:24 -04:00
коммит произвёл GitHub
родитель 9a2d96073e
Коммит 17d11db395
16 изменённых файлов: 321 добавлений и 4 удалений

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

@@ -79,6 +79,32 @@ func (_m *SessionStore) Get(c request.CTX, sessionIDOrToken string) (*model.Sess
return r0, r1
}
// GetLRUSessions provides a mock function with given fields: c, userID, limit, offset
func (_m *SessionStore) GetLRUSessions(c request.CTX, userID string, limit uint64, offset uint64) ([]*model.Session, error) {
ret := _m.Called(c, userID, limit, offset)
var r0 []*model.Session
var r1 error
if rf, ok := ret.Get(0).(func(request.CTX, string, uint64, uint64) ([]*model.Session, error)); ok {
return rf(c, userID, limit, offset)
}
if rf, ok := ret.Get(0).(func(request.CTX, string, uint64, uint64) []*model.Session); ok {
r0 = rf(c, userID, limit, offset)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Session)
}
}
if rf, ok := ret.Get(1).(func(request.CTX, string, uint64, uint64) error); ok {
r1 = rf(c, userID, limit, offset)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetSessions provides a mock function with given fields: c, userID
func (_m *SessionStore) GetSessions(c request.CTX, userID string) ([]*model.Session, error) {
ret := _m.Called(c, userID)