-
Notifications
You must be signed in to change notification settings - Fork 75
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 support for CSP hashes #100
Comments
|
Currently have the issue that some inline styles are not loading properly besides having the There should be support for |
|
Note that nonces are already supported, those could perhaps solve the problem?
|
|
In fact, nonces is what I do. Still would prefer to use hashes instead. |
|
Currently, I use the tag helpers. This gets rid of the browser issues, but it is not something that can be configured centrally and requires the usage of ASP.NET MVC. In other projects, it is more tricky to do that, since there might be no MVC at all. Maybe there is a solution I have missed? |
|
Pages with hashes in them can be cached, while nonces cannot. |
|
I have the issue that a page gets generated by a library that I am using and I am unable to put a nonce on it. The current solution is to allow |
|
This is a big issue right now since many web browsers block inline-scripting as well by ignoring things like safe-inline. How to add hashes to the white list in CustomSources? I can't find documentation on how to use nonces either, except for using the NWebsec Tag Helpers package. |
|
This seems like a bit of a no-brainer, can you allow a hash as a valid value for a script source? Nonces are a halfway-there approach and they're a good start, but it'd be great if NWebSec enabled a stricter definition of what's allowed to run. |
|
Yup, it will be added but there are a couple of other things that need to be sorted first.
… |
|
If one does not have many inline scripts the following workaround can be used: app.UseCsp(options => options
.DefaultSources(s => s.Self())
.ScriptSources(s =>
{
s.Self().CustomSources("https://example.com/foo/lib.js",
"https://www.example.com/bar/lib.js");
// Force hashes into custom sources. Can't be done with CustomSources(...)
// because CustomSources(...) checks if strings are uris
s.CustomSources = s.CustomSources.Concat(new [] { "'sha256-...='"});
}) |
|
Released |
I have added the hashes but still getting the same CSP error. Would you please take a look at the below code snippet: Erorr Deatils: for Script; Refused to load the script 'http://platform.twitter.com/widgets.js' because it violates the following Content Security Policy directive: "script-src 'self' 'sha256-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=' Thanks, |
|
Where can we find documentation on the hash support? |
Here is a really good blog post showing how it can be done.
The text was updated successfully, but these errors were encountered: