diff --git a/pkg/keycloak/proxy/cookies.go b/pkg/keycloak/proxy/cookies.go index 76026207..8c3ece4a 100644 --- a/pkg/keycloak/proxy/cookies.go +++ b/pkg/keycloak/proxy/cookies.go @@ -59,6 +59,8 @@ func (r *OauthProxy) DropCookie(wrt http.ResponseWriter, host, name, value strin cookie.SameSite = http.SameSiteStrictMode case constant.SameSiteLax: cookie.SameSite = http.SameSiteLaxMode + case constant.SameSiteNone: + cookie.SameSite = http.SameSiteNoneMode } http.SetCookie(wrt, cookie) @@ -87,6 +89,8 @@ func (r *OauthProxy) GetMaxCookieChunkLength(req *http.Request, cookieName strin maxCookieChunkLength -= len("SameSite=Strict ") case constant.SameSiteLax: maxCookieChunkLength -= len("SameSite=Lax ") + case constant.SameSiteNone: + maxCookieChunkLength -= len("SameSite=None ") } if r.Config.SecureCookie { diff --git a/pkg/testsuite/cookies_test.go b/pkg/testsuite/cookies_test.go index 0cea1db7..4806a3a1 100644 --- a/pkg/testsuite/cookies_test.go +++ b/pkg/testsuite/cookies_test.go @@ -203,7 +203,7 @@ func TestSameSiteCookie(t *testing.T) { proxy.DropCookie(resp, req.Host, "test-cookie", "test-value", 0) assert.Equal(t, resp.Header().Get("Set-Cookie"), - "test-cookie=test-value; Path=/", + "test-cookie=test-value; Path=/; SameSite=None", "we have not set the cookie, headers: %v", resp.Header()) } @@ -268,11 +268,11 @@ func TestGetMaxCookieChunkLength(t *testing.T) { proxy.Config.SecureCookie = true proxy.Config.SameSiteCookie = "Strict" proxy.Config.CookieDomain = "1234567890" - assert.Equal(t, proxy.GetMaxCookieChunkLength(req, "1234567890"), 4017, + assert.Equal(t, 4017, proxy.GetMaxCookieChunkLength(req, "1234567890"), "cookie chunk calculation is not correct") proxy.Config.SameSiteCookie = "Lax" - assert.Equal(t, proxy.GetMaxCookieChunkLength(req, "1234567890"), 4020, + assert.Equal(t, 4020, proxy.GetMaxCookieChunkLength(req, "1234567890"), "cookie chunk calculation is not correct") proxy.Config.HTTPOnlyCookie = false @@ -280,7 +280,7 @@ func TestGetMaxCookieChunkLength(t *testing.T) { proxy.Config.SecureCookie = false proxy.Config.SameSiteCookie = "None" proxy.Config.CookieDomain = "" - assert.Equal(t, proxy.GetMaxCookieChunkLength(req, ""), 4021, + assert.Equal(t, 4007, proxy.GetMaxCookieChunkLength(req, ""), "cookie chunk calculation is not correct") }