We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8cefd5f commit e6157cbCopy full SHA for e6157cb
1 file changed
djangosaml2/utils.py
@@ -18,6 +18,7 @@
18
import zlib
19
from functools import lru_cache, wraps
20
from typing import Optional
21
+import importlib.metadata
22
23
from django.conf import settings
24
from django.core.exceptions import ImproperlyConfigured
@@ -254,4 +255,14 @@ def _django_csp_update_decorator():
254
255
else:
256
# autosubmit of forms uses nonce per default
257
# form-action https: to send data to IdPs
- return csp_update(FORM_ACTION=["https:"])
258
+ try:
259
+ csp_version = importlib.metadata.version("django-csp")
260
+ except importlib.metadata.PackageNotFoundError:
261
+ csp_version = "0"
262
+
263
+ major_version = int(csp_version.split(".")[0])
264
265
+ if major_version >= 4:
266
+ return csp_update({"form-action": ["https:"]})
267
+ else:
268
+ return csp_update(FORM_ACTION=["https:"])
0 commit comments