-
Notifications
You must be signed in to change notification settings - Fork 31
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
Safely migrating existing web app cookies to Partitioned #78
Comments
Thanks for the question, @GREsau! First, as it pertains to finding a more elegant solution for your use-case, I would recommend looking into the FedCM API, since that is the preferred solution to keep login working post-third-party cookie phaseout. Secondly, note that for Chrome, we are planning to deploy some short-term heuristics to keep login use cases such as yours working; so if your user flow triggers the heuristics, you may find that your iframe continues to retain access to unpartitioned third-party cookies. Now, getting to your question - given the complications that you pointed out with using identical cookie names with different attributes, I think it may be best to maintain two duplicate/synced cookies with different names for the medium-term. This means, you should keep your current
Do you see any issues with this scheme? |
Hi @krgovind, thanks for the info - and sorry for the slow response, I was off of work for most of december We looked into FedCM but it wasn't really viable for us in the short/medium-term for a few reasons. Off the top of my head, these include:
I don't think the exemption heuristics would work for us without tweaking our auth flow, since the first cookie is set before any user interaction (before the login page is even displayed). Even if it did work, this would of course just be kicking the can down the road - assuming these heuristics are just temporary, we would still need to find a longer-term fix. Introducing new partitioned cookies with an extra For now, the solution we're going ahead with is basically to:
Our full solution is a little more complicated with some extra steps in order to facilitate a backward-/forward-compatible "expand-contract" rollout, but that's the gist of it. This means that we don't need to update any code that reads cookies, since they'll have the same name whether or not they're partitioned. It does mean we need to run some extra logic when setting cookies, but fortunately we're able to do this for all cookies with a custom module on our webserver, so we don't need to hunt down each individual place in code where we set a cookie. This does of course mean we will be violating the "SHOULD NOT"s of RFC 6265 which isn't great. But practically, I think the risk of breaking non-compliant browsers is less than the cost of having to find alternative solutions that we can implement in a timely manner. |
@GREsau Thanks for the feedback regarding FedCM. I'll pass this on to others on my team who are thinking about login use-cases. Glad to hear that you've figured out a suboptimal scheme, but one that works for you. |
Very belated reply: Transition from unpartitioned to partitioned cookies provides a basic overview of this process. |
TL;DR: Is there a recommended process for migrating a web app to issue cookies as
Partitioned
which does not break ongoing cookies/sessions?We currently have a big, old, complex, monolithic web app which uses cookies mostly for authentication. Our app is sometimes used in a cross-origin iframe e.g. embedded in a CRM, and sometimes used in a top-level context (and sometimes both, in the same browser session).
To avoid being broken by third-party cookie blocking, we are intending to add the
Partitioned
attribute to all cookies issued by our app. Being unable to share cookies between the iframe and top-level context is a bit of a problem, but we're mostly working-around it with some (unfortunately slightly hacky) popups andwindow.opener
shenanigans.Our biggest problem is finding a way to safely roll-out the change to make cookies
Partitioned
in a backward-compatible manner (and forward-compatible, in case we need to temporarily roll-back the change), which we need to do before browsers actually start blocking third-party cookies. Some of our enterprise customers have quite slow-moving browser update policies, which means our solution should ideally still work for browsers that don't understand/respect thePartitioned
attribute.Naively making all new
Set-Cookie
headers have thePartitioned
attribute would cause problems for users who have ongoing sessions at the point we apply the change, e.g.auth=some.session.data
Partitioned
in allSet-Cookie
headersSet-Cookie: auth=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Partitioned
We can work-around this specific case by, when issuing
Set-Cookie
header with anExpires
value in the past (i.e. when deleting a cookie), duplicate the header - once withPartitioned
, and once without. This ensures that we delete the cookie no matter whether it was issued asPartitioned
or not - although it does violate the recommendations of RFC 6265:However, we still have a problem when trying to update an existing cookie without deleting it, e.g.
auth=some.session.data
Partitioned
in allSet-Cookie
headersSet-Cookie: auth=renewed.session.data; Partitioned
Cookie: auth=some.session.data; auth=renewed.session.data
In this case, we would generally want the server to always use the most recently-set cookie value. But with the current browser behaviour, we would need to rely on this always being the last value for the cookie name - this is also against RFC 6265:
The text was updated successfully, but these errors were encountered: