Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further production fixex - empty hash, upgrade Django #4119

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions privaterelay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
the_hash = base64.b64encode(sha256(content).digest()).decode()
hashes.append("'sha256-%s'" % the_hash)

# The sourceMappingURL is slightly different when loaded dynamically
# in next 14.0.0. Capture hash for alternate.
# The sourceMappingURL comment is slightly different when loaded dynamically
# in next 14.0.0. Capture the hash for alternate comment.
if content.endswith(b"map*/"):
space_content = content[:-2] + b" " + content[-2:]
assert space_content.endswith(b"map */")
Expand All @@ -153,6 +153,12 @@
hashes.sort()
csp_style_values.extend(hashes)

# Add the hash for an empty string (sha256-47DEQp...)
# next 14.0.0 injects an empty style element and then adds the content
empty_hash = base64.b64encode(sha256().digest()).decode()
csp_style_values.append("'sha256-%s'" % empty_hash)


CSP_STYLE_SRC = tuple(csp_style_values)

CSP_IMG_SRC = ["'self'"] + AVATAR_IMG_SRC
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
boto3==1.28.78
codetiming==1.4.0
cryptography==41.0.5
Django==3.2.22
Django==4.2.7
dj-database-url==2.1.0
django-allauth==0.54.0
django-cors-headers==4.3.0
Expand Down