File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 18
18
import zlib
19
19
from functools import lru_cache , wraps
20
20
from typing import Optional
21
+ import importlib .metadata
21
22
22
23
from django .conf import settings
23
24
from django .core .exceptions import ImproperlyConfigured
@@ -254,4 +255,14 @@ def _django_csp_update_decorator():
254
255
else :
255
256
# autosubmit of forms uses nonce per default
256
257
# form-action https: to send data to IdPs
257
- 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:" ])
You can’t perform that action at this time.
0 commit comments