Skip to content

Commit

Permalink
Add "Partitioned" flag to our cookies (#3830)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Jan 25, 2024
1 parent 6af2d38 commit 645c9d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pretix/helpers/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def set_cookie_without_samesite(request, response, key, *args, **kwargs):
# This will only work on secure cookies as well
# https://www.chromestatus.com/feature/5633521622188032
response.cookies[key]['secure'] = is_secure
# CHIPS
response.cookies[key]['Partitioned'] = True


# Based on https://www.chromium.org/updates/same-site/incompatible-clients
Expand Down
8 changes: 8 additions & 0 deletions src/pretix/helpers/monkeypatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#
import types
from datetime import datetime
from http import cookies

from PIL import Image
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -88,7 +89,14 @@ def httpadapter_send(self, request, stream=False, timeout=None, verify=True, cer
HTTPAdapter.send = httpadapter_send


def monkeypatch_cookie_morsel():
# See https://code.djangoproject.com/ticket/34613
cookies.Morsel._flags.add("partitioned")
cookies.Morsel._reserved.setdefault("partitioned", "Partitioned")


def monkeypatch_all_at_ready():
monkeypatch_vobject_performance()
monkeypatch_pillow_safer()
monkeypatch_requests_timeout()
monkeypatch_cookie_morsel()

0 comments on commit 645c9d5

Please sign in to comment.