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

Support for Partitioned cookies attribute #112713

Open
giles-v opened this issue Dec 4, 2023 · 11 comments · May be fixed by #112714
Open

Support for Partitioned cookies attribute #112713

giles-v opened this issue Dec 4, 2023 · 11 comments · May be fixed by #112714
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@giles-v
Copy link

giles-v commented Dec 4, 2023

Feature or enhancement

Proposal:

Chrome is phasing out support for Third Party Cookies in Q1 2024, and for several key use cases, the proposed solution is CHIPS (https://github.com/privacycg/CHIPS).

See Chrome's blogpost about these changes: https://developer.chrome.com/en/docs/privacy-sandbox/third-party-cookie-phase-out/#partitioned

Currently, cookies with the Partitioned attribute cannot be set from within the http.cookies library. I'm proposing that we add support for that attribute.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@giles-v giles-v added the type-feature A feature request or enhancement label Dec 4, 2023
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Dec 4, 2023
@giles-v
Copy link
Author

giles-v commented Jan 17, 2024

Hey there @AlexWaygood, just a ping on this issue per the contributors guide -- this issue and the PR have been up for about six weeks now. A review would be appreciated, thank you!

@Flecart
Copy link

Flecart commented Feb 10, 2024

I need this feature, for starlette. encode/starlette#2500.

Flecart added a commit to Flecart/starlette that referenced this issue Feb 10, 2024
the test should fail, we need to wait for python/cpython#112713
@merwok
Copy link
Member

merwok commented Feb 12, 2024

AFAIU this is a proposed / experimental thing for now, and from MDN it’s not implemented in Firefox or Safari yet.
If this becomes a standard (with WHATWG or W3C), it could be considered for Python.

@gpshead gpshead added the 3.13 bugs and security fixes label Feb 14, 2024
@gpshead gpshead self-assigned this Feb 14, 2024
@merwok
Copy link
Member

merwok commented Feb 14, 2024

@gpshead could you reply to my note here before going on with the PR?

@gpshead
Copy link
Member

gpshead commented Feb 14, 2024

Sorry I missed your comment earlier. Holding off awaiting a standard is fine, I misread it and thought it'd been implemented already rather than seeing those were the prior attempts.

This really just seems to be adding an attribute that adds an additional string to a cookie. If it winds up not meaning anything, it wouldn't be the end of the world - though we'd obviously need different docs than what the PR contains right now.

What's the alternative within the existing http.cookies API for adding Partitioned to a cookie it creates and checking for Partitioned when parsing today without implementing your own parsing? (that could expand into a bigger question about whether the stdlib API is actually a good one)

@gpshead gpshead removed the 3.13 bugs and security fixes label Feb 14, 2024
@gpshead gpshead assigned merwok and unassigned gpshead Feb 14, 2024
@Flecart
Copy link

Flecart commented Feb 19, 2024

I would like to note that https://developers.google.com/privacy-sandbox/3pcd#report-issues google is already rolling out this change for 1% of users.

@mst-kialo
Copy link

mst-kialo commented Feb 21, 2024

We had to patch in support for partitioned cookies ourselves in preparation for the switch to partitioned cookies in Edge / Chrome because that will likely be coming for every Chrome and Edge users no matter what. For us that makes the experience of users in embedded contexts much smoother since we know that we will be supporting embedding even after the phaseout of 3rd party cookies has been completed sometime this year on those two browsers.

It would be nice not having to patch it because the accepted attributes for morsels are as restrictive as they currently are, especially since unknown properties are simply ignored by other browsers. Firefox and Safari don't care if the Partitioned property is set and continue working with the cookies as is.

In conclusion waiting for this PR to be pulled until this has become a standard results in either a worse experience for users of chromium browsers or having to manually patch it in anyway.
Furthermore Safari and Firefox seem to have positioned themselves open to implement support for it sometime down the road as well:

WebKit/standards-positions#50
mozilla/standards-positions#678

@merwok merwok added the 3.13 bugs and security fixes label Feb 21, 2024
@merwok
Copy link
Member

merwok commented Feb 21, 2024

OK, there seems to be consensus, so this can be added to 3.13

ep1cman added a commit to ep1cman/uiprotect that referenced this issue Jun 11, 2024
As of UniFi Protect 4.0.5, they have started sending the cookie flag "partitioned".
Python currently does not know about this (planned to be fixed in 3.13 python/cpython#112713).
This causes the cookie to be considered invalid, and thus the auth cookie is never saved.
Since unifi protect rate limits authentication attempts this leads to 501 errors after a few requests are made.

This commit adds `partitioned` to the list of cookie flags the standard library accepts as valid.
Thus allowing the cookie to be correctly parsed and saved.
@picnixz picnixz removed the 3.13 bugs and security fixes label Sep 9, 2024
@picnixz
Copy link
Contributor

picnixz commented Sep 9, 2024

FTR: issues with type-feature always target the latest branch.

@merwok
Copy link
Member

merwok commented Sep 9, 2024

ok but why remove the tag indicating the version that a feature will or does appear in?

@picnixz
Copy link
Contributor

picnixz commented Sep 9, 2024

I think it's because the feature may or may not be included in that version when it's being merged. (Actually, I'm only following the devguide: https://devguide.python.org/triage/labels/#type-labels). We however use the 3.x labels for indicating the versions being affected by bugs (and those labels are then mirrored on the PR with "need backport 3.x")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
Development

Successfully merging a pull request may close this issue.

7 participants