Skip to content

Commit

Permalink
Merge pull request #5622 from benjaoming/fix-csp-dev
Browse files Browse the repository at this point in the history
CSP header should not block development Central Server
  • Loading branch information
Benjamin Balder Bach authored Dec 3, 2019
2 parents 8937a36 + 504a23f commit 64fe3fd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kalite/distributed/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ def process_response(self, request, response):
if getattr(settings, 'CSP_REPORT_ONLY', False):
header += '-Report-Only'

response[header] = "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: *.learningequality.org; img-src data: *; script-src 'self' *.learningequality.org 'unsafe-eval' 'unsafe-inline'"
response[header] = "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: *.learningequality.org{append_srcs}; img-src data: *; script-src 'self' *.learningequality.org 'unsafe-eval' 'unsafe-inline'"

# Add potentially alternative hosts configured as central server
if "learningequality.org" not in settings.CENTRAL_SERVER_HOST:
response[header] = response[header].format(
append_srcs=" " + settings.CENTRAL_SERVER_HOST
)
else:
response[header] = response[header].format(append_srcs="")

return response


Expand Down

0 comments on commit 64fe3fd

Please sign in to comment.