-
Notifications
You must be signed in to change notification settings - Fork 373
Adds support for SameSite cookie attribute #165
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
Conversation
aefa750
to
600b387
Compare
gofmt issue, fixed and re-running CI. |
Waiting on #167 to build this against Go 1.11.x - running into the Go 1.4.x vet issue. |
600b387
to
594db95
Compare
Rebased to run against latest CI config. |
Maybe I'm missing something, but shouldn't |
Good catch. Let me add tests to catch this in future (copying structs,
field by field, is wonderfully error prone).
…On Mon, Sep 24, 2018 at 12:51 PM Niels Widger ***@***.***> wrote:
Maybe I'm missing something, but shouldn't sessions.NewCookie set SameSite
in the cookie it returns based on the value of options.SameSite?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#165 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcHUuvRxCY5nLNmPKi77mJurLMF9Dks5ueTfNgaJpZM4WXuvN>
.
|
Sounds good, let me know if I can be of any help. I'm happy to submit a PR to fix this if you're busy. |
Would be great if you could submit a PR for the fix + test.
You'll also need to take into account Go 1.11 vs. earlier versions, which
means two versions of NewCookie + build flags.
…On Thu, Sep 27, 2018 at 5:34 AM Niels Widger ***@***.***> wrote:
Sounds good, let me know if I can be of any help. I'm happy to submit a PR
to fix this if you're busy.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#165 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcJV_MJDMdC0ger3_LZu4g6K2zeQDks5ufMW7gaJpZM4WXuvN>
.
|
Yea, I was thinking that was going to be necessary. I'll see what I can do! |
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.
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.
Addresses #164
Adds support for the
SameSite
attribute introduced in Go 1.11 - a new cookie attribute introduced to further prevent CSRF attacks: https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60/