Set http.Cookie's SameSite field in NewCookie for Go 1.11 or later#170
Merged
kisielk merged 2 commits intogorilla:masterfrom Sep 28, 2018
Merged
Set http.Cookie's SameSite field in NewCookie for Go 1.11 or later#170kisielk merged 2 commits intogorilla:masterfrom
kisielk merged 2 commits intogorilla:masterfrom
Conversation
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.
Author
|
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. |
Contributor
|
Restarted the job. It hit the 10 minute timeout with no output, which is
likely a Travis infrastructure issue.
Will review the PR today - thanks for submitting this!
…On Fri, Sep 28, 2018 at 5:37 AM Niels Widger ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#170 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcNf2O7x1BGAfi-pN9qZf1GiFoqeWks5ufhgggaJpZM4W-YfW>
.
|
Author
|
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? |
Contributor
|
@nwidger 100%. Doing that now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back 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 #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.