Skip to content

Commit 8995cb6

Browse files
zvlbJneville0815
authored andcommitted
fix(ui): Update default and max count for maxCookieNumber (argoproj#14979)
* Update default and max count for maxCookieNumber Signed-off-by: zvlb <vl.zemtsov@gmail.com> Signed-off-by: Jimmy Neville <jimmyeneville@gmail.com>
1 parent aeb7bf2 commit 8995cb6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

util/http/http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
const maxCookieLength = 4093
1919

2020
// max number of chunks a cookie can be broken into. To be compatible with
21-
// widest range of browsers, we shouldn't create more than 30 cookies per domain
22-
var maxCookieNumber = env.ParseNumFromEnv(common.EnvMaxCookieNumber, 10, 0, 30)
21+
// widest range of browsers, you shouldn't create more than 30 cookies per domain
22+
var maxCookieNumber = env.ParseNumFromEnv(common.EnvMaxCookieNumber, 20, 0, math.MaxInt64)
2323

2424
// MakeCookieMetadata generates a string representing a Web cookie. Yum!
2525
func MakeCookieMetadata(key, value string, flags ...string) ([]string, error) {

util/http/http_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ func TestCookieMaxLength(t *testing.T) {
1515

1616
// keys will be of format foo, foo-1, foo-2 ..
1717
cookies, err = MakeCookieMetadata("foo", strings.Repeat("_", (maxCookieLength-5)*maxCookieNumber))
18-
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")
18+
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")
1919
assert.Equal(t, 0, len(cookies))
2020
}
2121

22+
func TestCookieWithAttributes(t *testing.T) {
23+
flags := []string{"SameSite=lax", "httpOnly"}
24+
25+
cookies, err := MakeCookieMetadata("foo", "bar", flags...)
26+
assert.NoError(t, err)
27+
assert.Equal(t, "foo=bar; SameSite=lax; httpOnly", cookies[0])
28+
}
29+
2230
func TestSplitCookie(t *testing.T) {
2331
cookieValue := strings.Repeat("_", (maxCookieLength-6)*4)
2432
cookies, err := MakeCookieMetadata("foo", cookieValue)

0 commit comments

Comments
 (0)