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

Set http.Cookie's SameSite field in NewCookie for Go 1.11 or later #170

Merged
merged 2 commits into from Sep 28, 2018

Conversation

nwidger
Copy link
Contributor

@nwidger nwidger commented Sep 28, 2018

Set the returned http.Cookie's SameSite field to the value of the
SameSite field in the Options struct passed into NewCookie. This
fixes an oversight made in PR #165 which was made to address issue

Add a newCookieFromOptions function which takes a name, value and
Options struct and returns an http.Cookie. There are two
newCookieFromOptions implementations, one for Go 1.11 and later which
sets SameSite and one for earlier Go versions which does not.

Add new tests TestNewCookieFromOptions and
TestNewCookieFromOptionsSameSite which ensure that the values passed
to newCookieFromOptions are properly set in the returned cookie. The
test TestNewCookieFromOptionsSameSite only runs if running Go 1.11 and
later.

Set the returned http.Cookie's SameSite field to the value of the
SameSite field in the Options struct passed into NewCookie.  This
fixes an oversight made in PR gorilla#165 which was made to address issue

Add a newCookieFromOptions function which takes a name, value and
Options struct and returns an http.Cookie.  There are two
newCookieFromOptions implementations, one for Go 1.11 and later which
sets SameSite and one for earlier Go versions which does not.

Add new tests TestNewCookieFromOptions and
TestNewCookieFromOptionsSameSite which ensure that the values passed
to newCookieFromOptions are properly set in the returned cookie.  The
test TestNewCookieFromOptionsSameSite only runs if running Go 1.11 and
later.
This package is meant to work on Go versions going back to Go 1.3,
which means tests can't use testing.T.Run which doesn't exists in Go
1.6 and earlier.
@nwidger
Copy link
Contributor Author

nwidger commented Sep 28, 2018

FYI, it looks like the Go 1.4 Travis job failed because it timed out. I'm not sure if that's my fault or whether Travis has sporadic failures like that. I don't see a way to retry that job, but let me know if there's anything else I can do.

@elithrar
Copy link
Contributor

elithrar commented Sep 28, 2018 via email

@elithrar elithrar self-assigned this Sep 28, 2018
@kisielk kisielk merged commit f57b7e2 into gorilla:master Sep 28, 2018
@nwidger
Copy link
Contributor Author

nwidger commented Sep 29, 2018

Thanks for merging this. Do you think a new release is in order since the (allegedly broken) SameSite support was the headline feature for the most recent v1.1.2 release?

@elithrar
Copy link
Contributor

elithrar commented Oct 5, 2018

@nwidger 100%. Doing that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants