-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 non Same-Site Cookies set on first request #44574
base: master
Are you sure you want to change the base?
Allow non Same-Site Cookies set on first request #44574
Conversation
37f6382
to
1c28f60
Compare
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! |
I can confirm that this solution is working and would appreciate this being merged. |
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.
I understand the idea of the fix and why it is not working correctly at the moment, but I fail to see why this is necessary in the first place. What use-case does this fix? When do you already have a cookie present?
@@ -563,7 +563,7 @@ private static function performSameSiteCookieProtection(\OCP\IConfig $config): v | |||
return; | |||
} | |||
|
|||
if (count($_COOKIE) > 0) { | |||
if (count($_COOKIE) > 0 && (isset($_COOKIE['nc_sameSiteCookielax']) || isset($_COOKIE['nc_sameSiteCookiestrict']))) { |
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.
if (count($_COOKIE) > 0 && (isset($_COOKIE['nc_sameSiteCookielax']) || isset($_COOKIE['nc_sameSiteCookiestrict']))) { | |
if (isset($_COOKIE['nc_sameSiteCookielax']) || isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
And adjust the elseif below to be a simple else.
Signed-off-by: Thomas Pointhuber <[email protected]>
1c28f60
to
6dbd887
Compare
For me the use-case is to allow the DAVx5 App to sync my contacts and calendars to and AIO instance of nextcloud. |
Summary
When any cookie is already present during the first request (e.g. an Apache module may choose to set it for various reasons) a
412 Precondition Failed
error is returned on the first request. The second request works as intended as the Same-Site Cookies are now set correctly.This breaks for example CalDAV/CardDAV syncs with Davx5 as the request is not retried after the first failure.
The proposed fix is to check for the explicit existence of
nc_sameSiteCookielax
ornc_sameSiteCookiestrict
instead of just checking if any cookie exists. I used the proposed fix from the issue, but I think we can removecount($_COOKIE) > 0
as it looks redundant now.Checklist