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

Add nonces to font-src and make NGINX replace "CSP_NONCE" with a nonce to ensure vite can handle it #779

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .changeset/fuzzy-seas-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@matrix-widget-toolkit/widget-server': patch
---

Adjust how vite handles nonces
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_header Content-Security-Policy "default-src 'none'; font-src 'self' data: $__CSP_FONT_SRC__; style-src 'self' $__STYLE_CSP_NONCE__ $__CSP_STYLE_SRC__; script-src 'self' $__STYLE_CSP_NONCE__ $__CSP_SCRIPT_SRC__; img-src 'self' data: $__CSP_IMG_SRC__; connect-src 'self' $__CSP_CONNECT_SRC__; manifest-src 'self';";
add_header Content-Security-Policy "default-src 'none'; font-src 'self' data: $__CSP_FONT_SRC__ $__STYLE_CSP_NONCE__; style-src 'self' $__STYLE_CSP_NONCE__ $__CSP_STYLE_SRC__; script-src 'self' $__STYLE_CSP_NONCE__ $__CSP_SCRIPT_SRC__; img-src 'self' data: $__CSP_IMG_SRC__; connect-src 'self' $__CSP_CONNECT_SRC__; manifest-src 'self';";
5 changes: 5 additions & 0 deletions containers/widget-server/files/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ server {
location / {
# enable SSI for the files. We use it to inject the environment variables
ssi on;

sub_filter_once off;
sub_filter_types *;
sub_filter CSP_NONCE $cspNonce;

try_files $uri $uri/ /index.html;
}

Expand Down
Loading