diff --git a/cookie.go b/cookie.go index 6612662..fa70e7c 100644 --- a/cookie.go +++ b/cookie.go @@ -15,6 +15,7 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie { MaxAge: options.MaxAge, Secure: options.Secure, HttpOnly: options.HttpOnly, + Partitioned: options.Partitioned, } } diff --git a/cookie_go111.go b/cookie_go111.go index 9b58828..d5e9e62 100644 --- a/cookie_go111.go +++ b/cookie_go111.go @@ -16,6 +16,7 @@ func newCookieFromOptions(name, value string, options *Options) *http.Cookie { Secure: options.Secure, HttpOnly: options.HttpOnly, SameSite: options.SameSite, + Partitioned: options.Partitioned, } } diff --git a/cookie_test.go b/cookie_test.go index acb4efb..8e02fbc 100644 --- a/cookie_test.go +++ b/cookie_test.go @@ -14,14 +14,16 @@ func TestNewCookieFromOptions(t *testing.T) { maxAge int secure bool httpOnly bool + partitioned bool }{ - {"", "bar", "/foo/bar", "foo.example.com", 3600, true, true}, - {"foo", "", "/foo/bar", "foo.example.com", 3600, true, true}, - {"foo", "bar", "", "foo.example.com", 3600, true, true}, - {"foo", "bar", "/foo/bar", "", 3600, true, true}, - {"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true}, - {"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true}, - {"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false}, + {"", "bar", "/foo/bar", "foo.example.com", 3600, true, true, true}, + {"foo", "", "/foo/bar", "foo.example.com", 3600, true, true, true}, + {"foo", "bar", "", "foo.example.com", 3600, true, true, true}, + {"foo", "bar", "/foo/bar", "", 3600, true, true, true}, + {"foo", "bar", "/foo/bar", "foo.example.com", 0, true, true, true}, + {"foo", "bar", "/foo/bar", "foo.example.com", 3600, false, true, true}, + {"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, false, true}, + {"foo", "bar", "/foo/bar", "foo.example.com", 3600, true, true, false}, } for i, v := range tests { options := &Options{ @@ -30,6 +32,7 @@ func TestNewCookieFromOptions(t *testing.T) { MaxAge: v.maxAge, Secure: v.secure, HttpOnly: v.httpOnly, + Partitioned: v.partitioned, } cookie := newCookieFromOptions(v.name, v.value, options) if cookie.Name != v.name { @@ -53,5 +56,8 @@ func TestNewCookieFromOptions(t *testing.T) { if cookie.HttpOnly != v.httpOnly { t.Fatalf("%v: bad cookie httpOnly: got %v, want %v", i+1, cookie.HttpOnly, v.httpOnly) } + if cookie.Partitioned != v.partitioned { + t.Fatalf("%v: bad cookie partitioned: got %v, want %v", i+1, cookie.Partitioned, v.partitioned) + } } } diff --git a/options.go b/options.go index d33d076..ec07068 100644 --- a/options.go +++ b/options.go @@ -16,4 +16,5 @@ type Options struct { MaxAge int Secure bool HttpOnly bool + Partitioned bool } diff --git a/options_go111.go b/options_go111.go index af9cdf0..3214990 100644 --- a/options_go111.go +++ b/options_go111.go @@ -18,6 +18,7 @@ type Options struct { MaxAge int Secure bool HttpOnly bool + Partitioned bool // Defaults to http.SameSiteDefaultMode SameSite http.SameSite } diff --git a/vendor/github.com/gorilla/securecookie/README.md b/vendor/github.com/gorilla/securecookie/README.md index c3b9815..62e4ec7 100644 --- a/vendor/github.com/gorilla/securecookie/README.md +++ b/vendor/github.com/gorilla/securecookie/README.md @@ -55,6 +55,7 @@ func SetCookieHandler(w http.ResponseWriter, r *http.Request) { Path: "/", Secure: true, HttpOnly: true, + Partitioned: true, } http.SetCookie(w, cookie) }