Monkeypatch stock csrfmiddleware

This commit is contained in:
Kara Engelhardt
2026-07-20 16:47:05 +02:00
parent d47c435489
commit 898a10cc57
2 changed files with 10 additions and 13 deletions
+10
View File
@@ -42,6 +42,8 @@ from urllib3.util.connection import (
from urllib3.util.timeout import _DEFAULT_TIMEOUT
from pretix.helpers.reportlab import ThumbnailingImageReader
from pretix.multidomain.middlewares import CsrfViewMiddleware
from django.middleware.csrf import CsrfViewMiddleware as BaseCsrfMiddleware
_cgnat_net = ipaddress.ip_network('100.64.0.0/10')
@@ -251,6 +253,13 @@ def monkeypatch_reportlab_imagereader():
utils.ImageReader.__init__ = new_init
def monkeypatch_csrf_middleware():
# Some views from django or plugins use the middleware or the derived decorators directly,
# so we have to also patch the stock middleware
BaseCsrfMiddleware._get_secret = CsrfViewMiddleware._get_secret
BaseCsrfMiddleware._set_csrf_cookie = CsrfViewMiddleware._set_csrf_cookie
def monkeypatch_all_at_ready():
monkeypatch_vobject_performance()
monkeypatch_pillow_safer()
@@ -258,3 +267,4 @@ def monkeypatch_all_at_ready():
monkeypatch_urllib3_ssrf_protection()
monkeypatch_cookie_morsel()
monkeypatch_reportlab_imagereader()
monkeypatch_csrf_middleware()