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

Always set "Secure" when sending "SameSite=None" #30

Open
asterite opened this issue Feb 8, 2022 · 0 comments
Open

Always set "Secure" when sending "SameSite=None" #30

asterite opened this issue Feb 8, 2022 · 0 comments

Comments

@asterite
Copy link

asterite commented Feb 8, 2022

Hi! Thank you for this nice little gem 🙏

According to some sources, like this one, it seems if "SameSite=None" is specified then "Secure" must also be specified, otherwise the cookie will be blocked:

If SameSite=None is set, the cookie Secure attribute must also be set (or the cookie will be blocked).

So I'm thinking these lines:

next if !ssl && parser.chrome? # https://www.chromestatus.com/feature/5633521622188032
if ssl and not cookie =~ /;\s*secure/i
cookie << '; Secure'
end

could be changed to:

            if not cookie =~ /;\s*secure/i
              cookie << '; Secure'
            end

It seems that over HTTP, if you send "SameSite=None; Secure" then everything still works fine. At least for first-party contexts it works fine. And for third-party contexts, well, they must be "Secure" according to the spec, so it never makes sense to send "SameSite=None" without "Secure".

I can send a PR if you want! In the meantime I'm just monkeypatching the middleware on my app.

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

No branches or pull requests

1 participant