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