-
Notifications
You must be signed in to change notification settings - Fork 125
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 CSP & Cache Control headers #2478
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the headers different for /*
and /-/*
? It's a SPA, and there are user-facing pages on both paths, so I would think everything should have the same headers?
|
[[headers]] | ||
for = "/*" | ||
[headers.values] | ||
Content-Security-Policy = "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Shouldn't we use
script-src 'self'
? The application shouldn't be loading remote scripts - Same for styles
- Images may come from auth providers, so we need wider permissions there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script-src are inline and we have to calculate nonce of them, which can be problematic for developers. Sometimes we use open source libraries. But defailt-src is https
which gets applied to all.
netlify.toml
Outdated
Permissions-Policy = "geolocation=(),midi=(),sync-xhr=(self),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()" | ||
Referrer-Policy = "no-referrer" | ||
X-Frame-Options = "SAMEORIGIN" | ||
X-Xss-Protection = "1; mode=block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this has been deprecated: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://securityheaders.com/?q=ui.rilldata.io&followRedirects=on this doesn't require this so we can remove it.
netlify.toml
Outdated
[[headers]] | ||
for = "/-/*" | ||
[headers.values] | ||
cache-control = ''' | ||
max-age=0, | ||
no-cache, | ||
no-store, | ||
must-revalidate''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. The application is a SPA, so it serves static content on all routes. Any dynamic parameters in the query string will only be consumed client-side, not rendered in the content (so e.g. confirmation codes will not be cached).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, we can remove this as its not working as expected.
* Add CSP & Cache Control headers
Please go the the
Preview
tab and select the appropriate sub-template: