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

Allow sameSite in setCookie #2437

Closed
gregorybleiker opened this issue Sep 5, 2018 · 17 comments · Fixed by #6828
Closed

Allow sameSite in setCookie #2437

gregorybleiker opened this issue Sep 5, 2018 · 17 comments · Fixed by #6828
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cookies 🍪 type: enhancement Requested enhancement of existing feature

Comments

@gregorybleiker
Copy link

Current behavior:

setCookie has the options "domain", "name", "value", "path", "secure", "httpOnly", "expiry"

Desired behavior:

setCookie should also allow setting the "sameSite" option

Versions

Cypress 3.1.0

sameSite is described in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie

@bahmutov
Copy link
Contributor

Where do you see the options: docs, typescript, code?

@gregorybleiker
Copy link
Author

@bahmutov in the code of cypress...

COOKIE_PROPERTIES = "name value path domain secure httpOnly expiry".split(" ")

@jennifer-shehane jennifer-shehane added topic: cookies 🍪 type: enhancement Requested enhancement of existing feature pkg/driver This is due to an issue in the packages/driver directory labels Oct 20, 2018
@jm-hmbk
Copy link

jm-hmbk commented Nov 27, 2019

https://docs.adobe.com/content/help/en/target/using/implement-target/before-implement/privacy/google-chrome-samesite-cookie-policies.html
When we have SameSite in cypress ?

@katiejduane
Copy link

Is there any progress/update on this feature? The newest version of Chrome requires sameSite to be set and so our auth process is failing, as we can't set this value from within Cypress. A workaround is using electron but this isn't sustainable/desirable. Thank you!

@karenpetrie
Copy link

karenpetrie commented Mar 13, 2020

I'm also looking for this feature to be added. We have an app that requires sameSite to be set as True. The app requires authentication so I am passing the cookie to bypass physically logging in with the front end but it fails due to the sameSite not being set.

@flotwig
Copy link
Contributor

flotwig commented Mar 13, 2020

This can be added as soon as the code is done. @jm-hmbk @katiejduane @karenpetrie If you'd like to open a PR to speed things up, this should be a small change. @gregorybleiker has identified one of the areas that will need to be updated, and tests will need to be added in the 2_cookies_spec test.

Reading SameSite status is a breaking change that will need to wait for 5.0: #5070

@katiejduane
Copy link

@flotwig what do you mean when you say 'this can be added as soon as the code is done'? are you meaning once 5.0 is finished, one could theoretically make the change and make a PR? or are you referring to some other code? Sorry, just need a clarification! Thanks!

@flotwig
Copy link
Contributor

flotwig commented Mar 16, 2020

@katiejduane Once there is a PR merged that adds support for sameSite to cy.setCookie, it could be released with the next minor release of Cypress (currently 4.3.0) once merged. Nobody from the team is currently working on a PR for this, but contributions are welcome 😄

Adding it to cy.getCookie is a breaking change and needs to wait for the next major release of Cypress (currently, 5.0.0)

@katiejduane
Copy link

thanks for the quick response @flotwig ...so in order to do this i'd essentially have to clone the repo, make the required changes (ONLY for cy.setCookie(), not getCookie()), push up those changes on my own branch, and make a PR? sorry if this seems like a silly question, i've never contributed or made a PR to any repo but my own or my employer's 😬

@flotwig
Copy link
Contributor

flotwig commented Mar 18, 2020

@katiejduane yup, that's right!

@katiejduane
Copy link

@flotwig sorry to keep bothering you with questions but i saw that issue #6757 was assigned to you. does this mean you'll make the fix or should i still do my best to fix and make a PR? happy to try, just wanted to know if I don't need to. Electron is now also failing due to the cookie being blocked, so we can't get authorized at all right now using cy.request()

@flotwig
Copy link
Contributor

flotwig commented Mar 18, 2020

@katiejduane good eye, i'll probably add a fix for this issue as part of #6757 anyways so don't worry about it for now

@blaster151
Copy link

Just came here to figure out this issue - will eagerly await #6757 as well!

@katiejduane
Copy link

thanks @flotwig , we're essentially blocked right now (except in CI) because our application is in development, and the auth page is at a deployed URL, but the app is still sitting on localhost:3000, so a UI login is out of the question; and so can't run the tests at all. if you think there's a chance you won't have a fix for this with #6757 please let me know and i'll give it my best shot and make a PR. i'd already started making some adjustments before your most recent comments, but obviously am far, far less familiar with this code base than you are. sorry for all my own super verbose comments! 😬

@flotwig flotwig self-assigned this Mar 18, 2020
@katiejduane
Copy link

thank you @flotwig !!! 😁

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Mar 24, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Mar 27, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 27, 2020

The code for this is done in cypress-io/cypress#6828, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 30, 2020

Released in 4.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cookies 🍪 type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants