-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix incorrect setting of the SameSite cookie param #32462
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
Fix incorrect setting of the SameSite cookie param #32462
Conversation
Add samesite cookie param support in form key provider and admin tools
Hi @ihor-sviziev. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @ihor-sviziev. Thanks for the fixes.
Please, look at my suggestions, that doesn't change the main logic implemented by your PR, but improve code style
app/code/Magento/PageCache/view/frontend/web/js/form-key-provider.js
Outdated
Show resolved
Hide resolved
app/code/Magento/PageCache/view/frontend/web/js/form-key-provider.js
Outdated
Show resolved
Hide resolved
app/code/Magento/PageCache/view/frontend/web/js/form-key-provider.js
Outdated
Show resolved
Hide resolved
Apply suggestions from code review Co-authored-by: Denis Kopylov <[email protected]>
@magento run all tests |
I'll just add some info about reproducing this issue that we discussed with @engcom-Foxtrot in Slack: Example 1:
Actual result (before this PR) Expected result (with this PR) Example 2:
Actual result (before this PR)
❌ added 'lax' to the end of cookie domain; no samesite attribute Expected result (with this PR) |
Should we change capitalize first letter of 'lax' ? Change to 'Lax' |
@mrtuvn according to RFC - it's case insensitive: |
Hi @ihor-sviziev, thank you for your contribution! |
While waiting for a regular fix I can propose an easy way to workaround a "}lax" problem in cookies. As for me I don't like to penetrate deep into such complicated materials like overriding core jquery libraries. So I suggest to override a phtml template. For a hot-fix it is necessary to customize at your theme either at any other module a template vendor/magento/module-cookie/view/base/templates/html/cookie.phtml . You need to add to the template a new row http://screenshots.collabstar.com/vza/Selection_d75f109.png This will initialize a previously undefined field "_samesite" at a frontend script vendor/magento/module-cookie/view/base/web/js/jquery.storageapi.extended.js http://screenshots.collabstar.com/vza/Selection_53b8cb2.png The above mentioned operation allows to bypass a buggy part of a statement Since a "false" branch of the statement is incorrect and a "true" branch is OK we only need to define an argument "options.samesite". This allows to implement a positive scenario and omit a wrong "lax" assignment. Of course one can implement the fix in a gentle way by providing additional arguments to a block Have a nice fixing! |
Just note the fix also available in the quality patches tool as MC-41359. |
i have already pulled and merged the latest updates, and seems that your fix is already applied, but the issue still active, the only thing i need to know now where the cookie is coming from in order to add "secure" at the end. |
Hi @salehawal, |
@ihor-sviziev i am facing this issue on the admin only, the site is working fine |
@salehawal, again, it's not clear to me what are steps to reproduce, actual and expected results. Are the cookies getting set with js or with backend? Is it reproducing on clean magento installation? (It might be cause by some 3rd party extension). |
Description (*)
lex
suffix to the value, domain, or other params./CC @hostep
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)