210
210
"vng_api_common" ,
211
211
"notifications_api_common" ,
212
212
"drf_spectacular" ,
213
+ "drf_spectacular_sidecar" ,
213
214
"rest_framework" ,
214
215
"django_markup" ,
215
216
"solo" ,
@@ -953,9 +954,7 @@ def init_sentry(before_send: Callable | None = None):
953
954
# NOTE: make sure values are a tuple or list, and to quote special values like 'self'
954
955
955
956
# ideally we'd use BASE_URI but it'd have to be lazy or cause issues
956
- CSP_DEFAULT_SRC = [
957
- "'self'" ,
958
- ] + config (
957
+ CSP_DEFAULT_SRC = ["'self'" ] + config (
959
958
"CSP_EXTRA_DEFAULT_SRC" ,
960
959
default = [],
961
960
split = True ,
@@ -996,12 +995,16 @@ def init_sentry(before_send: Callable | None = None):
996
995
+ CORS_ALLOWED_ORIGINS
997
996
)
998
997
999
- CSP_IMG_SRC = CSP_DEFAULT_SRC + config (
1000
- "CSP_EXTRA_IMG_SRC" ,
1001
- default = [],
1002
- split = True ,
1003
- group = "Content Security Policy" ,
1004
- help_text = "Extra ``img-src`` sources for CSP other than ``CSP_DEFAULT_SRC``." ,
998
+ CSP_IMG_SRC = (
999
+ CSP_DEFAULT_SRC
1000
+ + ["data:" , "cdn.redoc.ly" ] # used by DRF spectacular
1001
+ + config (
1002
+ "CSP_EXTRA_IMG_SRC" ,
1003
+ default = [],
1004
+ split = True ,
1005
+ group = "Content Security Policy" ,
1006
+ help_text = "Extra ``img-src`` sources for CSP other than ``CSP_DEFAULT_SRC``." ,
1007
+ )
1005
1008
)
1006
1009
1007
1010
# affects <object> and <embed> tags, block everything by default but allow deploy-time
@@ -1016,8 +1019,13 @@ def init_sentry(before_send: Callable | None = None):
1016
1019
1017
1020
# we must include this explicitly, otherwise the style-src only includes the nonce because
1018
1021
# of CSP_INCLUDE_NONCE_IN
1019
- CSP_STYLE_SRC = CSP_DEFAULT_SRC
1020
- CSP_SCRIPT_SRC = CSP_DEFAULT_SRC
1022
+ CSP_STYLE_SRC = CSP_DEFAULT_SRC + [
1023
+ "'unsafe-inline'" ,
1024
+ "fonts.googleapis.com" ,
1025
+ ] # used by DRF spectacular
1026
+ CSP_SCRIPT_SRC = CSP_DEFAULT_SRC + ["'unsafe-inline'" ]
1027
+ CSP_FONT_SRC = ("'self'" , "fonts.gstatic.com" )
1028
+ CSP_WORKER_SRC = ("'self'" , "blob:" )
1021
1029
1022
1030
# firefox does not get the nonce from default-src, see
1023
1031
# https://stackoverflow.com/a/63376012
@@ -1033,9 +1041,3 @@ def init_sentry(before_send: Callable | None = None):
1033
1041
# CSP_SANDBOX # too much
1034
1042
1035
1043
CSP_UPGRADE_INSECURE_REQUESTS = False # TODO enable on production?
1036
-
1037
- CSP_EXCLUDE_URL_PREFIXES = (
1038
- # ReDoc/Swagger pull in external sources, so don't enforce CSP on API endpoints/documentation.
1039
- "/api/" ,
1040
- "/admin/" ,
1041
- )
0 commit comments