diff --git a/pyproject.toml b/pyproject.toml index 52057fc6f..dce253b3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,6 @@ dependencies = [ "bleach==6.4.0", "django==6.0.9", "django-countries==9.1.0", - "django-csp==4.0", "django-prometheus==2.5.0", "feedparser==6.0.14", "ipy==1.1", diff --git a/settings.py b/settings.py index 914420ce3..9dee71f25 100644 --- a/settings.py +++ b/settings.py @@ -2,7 +2,7 @@ import sys from os import path -from csp.constants import NONCE, SELF +from django.utils.csp import CSP # Set the debug values DEBUG = False @@ -56,7 +56,7 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.http.ConditionalGetMiddleware', - 'csp.middleware.CSPMiddleware', + 'django.middleware.csp.ContentSecurityPolicyMiddleware', ] # Base of the URL hierarchy @@ -97,15 +97,13 @@ SECURE_CONTENT_TYPE_NOSNIFF = True # CSP Settings -CONTENT_SECURITY_POLICY = { - "DIRECTIVES": { - "default-src": [SELF], - "script-src": [SELF, NONCE], - "img-src": [SELF, "data:"], - "base-uri": ["'none'"], - "form-action": [SELF], - "frame-ancestors": ["'none'"], - } +SECURE_CSP = { + "default-src": [CSP.SELF], + "script-src": [CSP.SELF, CSP.NONCE], + "img-src": [CSP.SELF, "data:"], + "base-uri": [CSP.NONE], + "form-action": [CSP.SELF], + "frame-ancestors": [CSP.NONE], } # Use new test runner @@ -252,7 +250,7 @@ 'django.template.context_processors.request', 'django.template.context_processors.debug', 'django.contrib.messages.context_processors.messages', - 'csp.context_processors.nonce', + 'django.template.context_processors.csp', 'main.context_processors.mastodon_link', ], "loaders": [ diff --git a/templates/devel/clock.html b/templates/devel/clock.html index 79d315011..eaa538703 100644 --- a/templates/devel/clock.html +++ b/templates/devel/clock.html @@ -61,7 +61,7 @@