Skip to content

Added support for SameSite=None cookie value#1358

Merged
jeremy merged 1 commit into
rack:masterfrom
amedia:master
May 10, 2019
Merged

Added support for SameSite=None cookie value#1358
jeremy merged 1 commit into
rack:masterfrom
amedia:master

Conversation

@hennikul

@hennikul hennikul commented May 9, 2019

Copy link
Copy Markdown
Contributor

This value was added in revision 3 of rfc6265bis:
https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#appendix-A.4

The value "None" indicates that cookie is used as a third party cookie. Chrome 76, due for release late July, will default to SameSite=Lax unless SameSite is set. The only way to set cookies used as third party cookies will be to set them with SameSite=None:
https://web.dev/samesite-cookies-explained/

@jeremy jeremy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks @hennikul

@jeremy jeremy merged commit c859bbf into rack:master May 10, 2019
@jrgns

jrgns commented Jul 30, 2019

Copy link
Copy Markdown

Any idea when will this be released?

@dbelling

Copy link
Copy Markdown

Is there a milestone or semantic version which these changes align to? Also curious as to when these will go live.

@geordanr

Copy link
Copy Markdown

Any update on when this will become generally available, given the upcoming changes to Chrome?

@bnorton

bnorton commented Nov 20, 2019

Copy link
Copy Markdown

I realize that releases of rack are few and far between but must I maintain a fork of rack for the sake of setting SameSite=None cookie values?!

@ioquatix

Copy link
Copy Markdown
Member

Nope, let's try to get this I the next release.

@ioquatix ioquatix added this to the v2.1.0 milestone Nov 20, 2019
@ioquatix

Copy link
Copy Markdown
Member

Just to check, this appears to be merged, so all we need is another release, right?

@bnorton

bnorton commented Nov 20, 2019

Copy link
Copy Markdown

Just to check, this appears to be merged, so all we need is another release, right?

@ioquatix that's what it looks like to me, if you were asking my opinion.

@ioquatix

Copy link
Copy Markdown
Member

Awesome, just wanted to check we weren't missing anything.

@jrgns

jrgns commented Nov 20, 2019

Copy link
Copy Markdown

Yes. There's a couple of things that's been merged, but never released.

See also #1387 and #1322

@bnorton

bnorton commented Dec 18, 2019

Copy link
Copy Markdown

For those who searched and found this thread/PR -- To make SameSite=None cookies work in a rails application (or any rack-based ruby app) you need to also FILTER OUT any clients that don't work nicely with this new flag, namely clients who mistreat the None value or drop the cookie when incompatible values are seen.

I have created this gist https://gist.github.com/bnorton/7dee72023787f367c48b3f5c2d71540f based on the rules and guidelines of the Chromium team => https://www.chromium.org/updates/same-site/incompatible-clients

@outreach-soren

Copy link
Copy Markdown

Any update on when we can expect this change to be released? The breaking version of chrome is expected to be promoted to stable in a little over a month.
https://www.chromestatus.com/features/schedule
I'd rather not have to create a fork to cherry-pick that commit in but I also don't want to have to wait til the last minute to implement this change.

@jrgns

jrgns commented Jan 1, 2020

Copy link
Copy Markdown

@outreach-soren See #1387 , looks like they're aiming for a release next week.

@outreach-soren

Copy link
Copy Markdown

Thanks!

alexspeller added a commit to alexspeller/rack that referenced this pull request Feb 1, 2020
…ack::Session::Cookie middleware

Recently, rack added support for SameSite=None cookies: rack#1358

However there is currently no way to set these cookies using the Rack::Session::Cookie
middleware without monkeypatching.

This pull request allows setting the SameSite value either by direct, literal
passthrough to the add_cookie_to_header method, or by passing a callable.

The callable option is required because some browsers are incompatible with
some values of the header, so it needs to be [different per-browser](https://www.chromium.org/updates/same-site/incompatible-clients).

Static usage:

```ruby
use Rack::Session::Cookie, secret: 'supersecret', same_site: :none
```

Dynamic usage:

```ruby
use Rack::Session::Cookie,
  secret: 'supersecret',
  same_site: lambda { |req, res| SameSite.value(req.user_agent) }
```
alexspeller added a commit to alexspeller/rack that referenced this pull request Feb 1, 2020
…ack::Session::Cookie middleware

Recently, rack added support for SameSite=None cookies: rack#1358

However there is currently no way to set these cookies using the Rack::Session::Cookie
middleware without monkeypatching.

This pull request allows setting the SameSite value either by direct, literal
passthrough to the add_cookie_to_header method, or by passing a callable.

The callable option is required because some browsers are incompatible with
some values of the header, so it needs to be [different per-browser](https://www.chromium.org/updates/same-site/incompatible-clients).

Static usage:

```ruby
use Rack::Session::Cookie, secret: 'supersecret', same_site: :none
```

Dynamic usage:

```ruby
use Rack::Session::Cookie,
  secret: 'supersecret',
  same_site: lambda { |req, res| SameSite.value(req.user_agent) }
```
jeremyevans pushed a commit that referenced this pull request Feb 4, 2020
…ack::Session::Cookie middleware

Recently, rack added support for SameSite=None cookies: #1358

However there is currently no way to set these cookies using the Rack::Session::Cookie
middleware without monkeypatching.

This pull request allows setting the SameSite value either by direct, literal
passthrough to the add_cookie_to_header method, or by passing a callable.

The callable option is required because some browsers are incompatible with
some values of the header, so it needs to be [different per-browser](https://www.chromium.org/updates/same-site/incompatible-clients).

Static usage:

```ruby
use Rack::Session::Cookie, secret: 'supersecret', same_site: :none
```

Dynamic usage:

```ruby
use Rack::Session::Cookie,
  secret: 'supersecret',
  same_site: lambda { |req, res| SameSite.value(req.user_agent) }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants