Skip to content

Adds support for SameSite cookie attribute - #165

Merged
elithrar merged 1 commit into
masterfrom
elithrar/same-site-go111
Sep 3, 2018
Merged

elithrar merged 1 commit into
masterfrom
elithrar/same-site-go111

Conversation

@elithrar

@elithrar elithrar commented Sep 3, 2018

Copy link
Copy Markdown
Contributor

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/

@elithrar

elithrar commented Sep 3, 2018

Copy link
Copy Markdown
Contributor Author

gofmt issue, fixed and re-running CI.

@elithrar

elithrar commented Sep 3, 2018

Copy link
Copy Markdown
Contributor Author

Waiting on #167 to build this against Go 1.11.x - running into the Go 1.4.x vet issue.

@elithrar
elithrar force-pushed the elithrar/same-site-go111 branch from 600b387 to 594db95 Compare September 3, 2018 15:28
@elithrar

elithrar commented Sep 3, 2018

Copy link
Copy Markdown
Contributor Author

Rebased to run against latest CI config.

@elithrar
elithrar merged commit 8154739 into master Sep 3, 2018
@elithrar
elithrar deleted the elithrar/same-site-go111 branch September 3, 2018 15:45
@nwidger

nwidger commented Sep 24, 2018

Copy link
Copy Markdown

Maybe I'm missing something, but shouldn't sessions.NewCookie set SameSite in the cookie it returns based on the value of options.SameSite?

@elithrar

elithrar commented Sep 26, 2018 via email

Copy link
Copy Markdown
Contributor Author

@nwidger

nwidger commented Sep 27, 2018

Copy link
Copy Markdown

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.

@elithrar

elithrar commented Sep 27, 2018 via email

Copy link
Copy Markdown
Contributor Author

@nwidger

nwidger commented Sep 27, 2018

Copy link
Copy Markdown

Yea, I was thinking that was going to be necessary. I'll see what I can do!

nwidger pushed a commit to nwidger/sessions that referenced this pull request 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 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.
@nwidger

nwidger commented Sep 28, 2018

Copy link
Copy Markdown

@elithrar I just created a new PR, let me know if there's anything I should fix up.

#170

kisielk pushed a commit that referenced this pull request 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.
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.

2 participants