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
@@ -34,6 +34,7 @@ var testUserAgents = []testUserAgent{
|
||||
{"Safari 8", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12"},
|
||||
{"Safari Mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B137 Safari/601.1"},
|
||||
{"Mobile App", "Mattermost Mobile/2.7.0+482 (Android; 13; sdk_gphone64_arm64)"},
|
||||
{"Mobile App", "Mattermost Mobile/233.234441.341234223421341234529099823109834440981234+abcdef3214eafeabc3242331129857301afesfffff1930a84e4bd2348fe129ac1309bd929dca3419af934bfe3089fcd (Android; 13; sdk_gphone64_arm64)"},
|
||||
}
|
||||
|
||||
func TestGetPlatformName(t *testing.T) {
|
||||
@@ -55,6 +56,7 @@ func TestGetPlatformName(t *testing.T) {
|
||||
"Macintosh",
|
||||
"iPhone",
|
||||
"Linux",
|
||||
"Linux",
|
||||
}
|
||||
|
||||
for i, userAgent := range testUserAgents {
|
||||
@@ -86,6 +88,7 @@ func TestGetOSName(t *testing.T) {
|
||||
"Mac OS",
|
||||
"iOS",
|
||||
"Android",
|
||||
"Android",
|
||||
}
|
||||
|
||||
for i, userAgent := range testUserAgents {
|
||||
@@ -117,6 +120,7 @@ func TestGetBrowserName(t *testing.T) {
|
||||
"Safari",
|
||||
"Safari",
|
||||
"Mobile App",
|
||||
"Mobile App",
|
||||
}
|
||||
|
||||
for i, userAgent := range testUserAgents {
|
||||
@@ -148,6 +152,7 @@ func TestGetBrowserVersion(t *testing.T) {
|
||||
"8.0.7",
|
||||
"9.0",
|
||||
"2.7.0+482",
|
||||
"233.234441.341234223421341234529099823109834440981234+abcdef3214eafeabc3242331129857301afesfffff1930a84e4bd2348fe129ac1309bd929d", // cut off at len 128
|
||||
}
|
||||
|
||||
for i, userAgent := range testUserAgents {
|
||||
|
||||
Ссылка в новой задаче
Block a user