Skip to content

Commit c641042

Browse files
authored
Merge pull request #2674 from minrk/csp-fixes
ensure "default-src 'none'" CSP is added to APIHandlers
2 parents c4a5dc0 + 0308dc7 commit c641042

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

notebook/base/handlers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def content_security_policy(self):
6262
6363
Can be overridden by defining Content-Security-Policy in settings['headers']
6464
"""
65+
if 'Content-Security-Policy' in self.settings.get('headers', {}):
66+
# user-specified, don't override
67+
return self.settings['headers']['Content-Security-Policy']
68+
6569
return '; '.join([
6670
"frame-ancestors 'self'",
6771
# Make sure the report-uri is relative to the base_url
@@ -72,9 +76,8 @@ def set_default_headers(self):
7276
headers = {}
7377
headers.update(self.settings.get('headers', {}))
7478

75-
if "Content-Security-Policy" not in headers:
76-
headers["Content-Security-Policy"] = self.content_security_policy
77-
79+
headers["Content-Security-Policy"] = self.content_security_policy
80+
7881
# Allow for overriding headers
7982
for header_name, value in headers.items():
8083
try:

0 commit comments

Comments
 (0)