Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#272: feat: Add support for paritioned attribute in cookies as per chrome 3rd party cookie phaseout #273

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cookie.go
Expand Up @@ -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,
}

}
1 change: 1 addition & 0 deletions cookie_go111.go
@@ -1,4 +1,4 @@
//go:build go1.11

Check failure on line 1 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / lint (1.20)

: # github.com/gorilla/sessions [github.com/gorilla/sessions.test]

Check failure on line 1 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

: # github.com/gorilla/sessions [github.com/gorilla/sessions.test]
// +build go1.11

package sessions
Expand All @@ -16,6 +16,7 @@
Secure: options.Secure,
HttpOnly: options.HttpOnly,
SameSite: options.SameSite,
Partitioned: options.Partitioned,

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / unit (1.20, ubuntu-latest)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / scan (1.20)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / lint (1.20)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / unit (1.20, macos-latest)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / scan (1.21)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / unit (1.21, ubuntu-latest)

unknown field Partitioned in struct literal of type http.Cookie

Check failure on line 19 in cookie_go111.go

View workflow job for this annotation

GitHub Actions / unit (1.21, macos-latest)

unknown field Partitioned in struct literal of type http.Cookie
}

}
20 changes: 13 additions & 7 deletions cookie_test.go
Expand Up @@ -14,14 +14,16 @@
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{
Expand All @@ -30,6 +32,7 @@
MaxAge: v.maxAge,
Secure: v.secure,
HttpOnly: v.httpOnly,
Partitioned: v.partitioned,
}
cookie := newCookieFromOptions(v.name, v.value, options)
if cookie.Name != v.name {
Expand All @@ -53,5 +56,8 @@
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 {

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.20, ubuntu-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / lint (1.20)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.20, macos-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.21, ubuntu-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 59 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.21, macos-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)
t.Fatalf("%v: bad cookie partitioned: got %v, want %v", i+1, cookie.Partitioned, v.partitioned)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.20, ubuntu-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / lint (1.20)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned) (typecheck)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.20, macos-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned) (typecheck)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.21, ubuntu-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)

Check failure on line 60 in cookie_test.go

View workflow job for this annotation

GitHub Actions / unit (1.21, macos-latest)

cookie.Partitioned undefined (type *http.Cookie has no field or method Partitioned)
}
}
}
1 change: 1 addition & 0 deletions options.go
Expand Up @@ -16,4 +16,5 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
}
1 change: 1 addition & 0 deletions options_go111.go
Expand Up @@ -18,6 +18,7 @@ type Options struct {
MaxAge int
Secure bool
HttpOnly bool
Partitioned bool
// Defaults to http.SameSiteDefaultMode
SameSite http.SameSite
}
1 change: 1 addition & 0 deletions vendor/github.com/gorilla/securecookie/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.