diff --git a/util/http/http.go b/util/http/http.go index 42981d62867fa..2572e739f009d 100644 --- a/util/http/http.go +++ b/util/http/http.go @@ -18,8 +18,8 @@ import ( const maxCookieLength = 4093 // max number of chunks a cookie can be broken into. To be compatible with -// widest range of browsers, we shouldn't create more than 30 cookies per domain -var maxCookieNumber = env.ParseNumFromEnv(common.EnvMaxCookieNumber, 10, 0, 30) +// widest range of browsers, you shouldn't create more than 30 cookies per domain +var maxCookieNumber = env.ParseNumFromEnv(common.EnvMaxCookieNumber, 20, 0, math.MaxInt64) // MakeCookieMetadata generates a string representing a Web cookie. Yum! func MakeCookieMetadata(key, value string, flags ...string) ([]string, error) { diff --git a/util/http/http_test.go b/util/http/http_test.go index cb37f74b39716..9655c5b42c249 100644 --- a/util/http/http_test.go +++ b/util/http/http_test.go @@ -15,10 +15,18 @@ func TestCookieMaxLength(t *testing.T) { // keys will be of format foo, foo-1, foo-2 .. cookies, err = MakeCookieMetadata("foo", strings.Repeat("_", (maxCookieLength-5)*maxCookieNumber)) - assert.EqualError(t, err, "the authentication token is 40880 characters long and requires 11 cookies but the max number of cookies is 10. Contact your Argo CD administrator to increase the max number of cookies") + assert.EqualError(t, err, "the authentication token is 81760 characters long and requires 21 cookies but the max number of cookies is 20. Contact your Argo CD administrator to increase the max number of cookies") assert.Equal(t, 0, len(cookies)) } +func TestCookieWithAttributes(t *testing.T) { + flags := []string{"SameSite=lax", "httpOnly"} + + cookies, err := MakeCookieMetadata("foo", "bar", flags...) + assert.NoError(t, err) + assert.Equal(t, "foo=bar; SameSite=lax; httpOnly", cookies[0]) +} + func TestSplitCookie(t *testing.T) { cookieValue := strings.Repeat("_", (maxCookieLength-6)*4) cookies, err := MakeCookieMetadata("foo", cookieValue)