Skip to content

Commit

Permalink
Merge pull request #2916 from cweider/csp
Browse files Browse the repository at this point in the history
feature(security): finalize Content Security Policy integration
  • Loading branch information
mlissner authored Jul 20, 2023
2 parents bc04eeb + 1947f64 commit 3fe0e4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions cl/settings/project/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
"'self'",
f"https://{AWS_S3_CUSTOM_DOMAIN}/", # for embedded PDFs
"https://hcaptcha.com/",
"https://*.hcaptcha.com",
"https://*.hcaptcha.com/",
"https://plausible.io/",
"https://api.stripe.com",
"https://api.stripe.com/",
)
CSP_FONT_SRC = (
"'self'",
Expand All @@ -98,16 +98,16 @@
"'self'",
f"https://{AWS_S3_CUSTOM_DOMAIN}/", # for embedded PDFs
"https://hcaptcha.com/",
"https://*.hcaptcha.com",
"https://js.stripe.com",
"https://hooks.stripe.com",
"https://*.hcaptcha.com/",
"https://js.stripe.com/",
"https://hooks.stripe.com/",
)
CSP_IMG_SRC = (
"'self'",
f"https://{AWS_S3_CUSTOM_DOMAIN}/",
"https://portraits.free.law",
"https://portraits.free.law/",
"data:", # @tailwindcss/forms uses data URIs for images.
"https://*.stripe.com",
"https://*.stripe.com/",
)
CSP_MEDIA_SRC = (
"'self'",
Expand All @@ -123,16 +123,16 @@
"'report-sample'",
f"https://{AWS_S3_CUSTOM_DOMAIN}/",
"https://hcaptcha.com/",
"https://*.hcaptcha.com",
"https://*.hcaptcha.com/",
"https://plausible.io/",
"https://js.stripe.com",
"https://js.stripe.com/",
)
CSP_STYLE_SRC = (
"'self'",
"'report-sample'",
f"https://{AWS_S3_CUSTOM_DOMAIN}/",
"https://hcaptcha.com/",
"https://*.hcaptcha.com",
"https://*.hcaptcha.com/",
"'unsafe-inline'",
)
CSP_DEFAULT_SRC = (
Expand All @@ -145,6 +145,3 @@
(DEVELOPMENT, TESTING)
): # Development and test aren’t used over HTTPS (yet)
CSP_UPGRADE_INSECURE_REQUESTS = True
if SENTRY_REPORT_URI:
CSP_REPORT_URI = SENTRY_REPORT_URI
CSP_REPORT_ONLY = True
2 changes: 1 addition & 1 deletion cl/visualizations/templates/new_visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="{% static "js/typeahead.jquery.js" %}"></script>
<script src="{% static "js/scotus_map_new.js" %}"></script>

<script type="application/javascript">
<script type="text/javascript" nonce="{{ request.csp_nonce }}">
var last_year = "{{ SCDB_LATEST_CASE }}";
var opinions = {
{% for viz in demo_viz %}
Expand Down

0 comments on commit 3fe0e4f

Please sign in to comment.