-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Explore removing inline module script for Blazor Wasm #36805
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
Comments
Reflects changes in dotnet/aspnetcore#36771 / dotnet/aspnetcore#34428. Created dotnet/aspnetcore#36805 to track removal of the inline script which requires the `sha256-v8v3RKRPmN4odZ1CWM5gw80QKPCCWMcpNeOmimNL2AA=` hash.
Note, if / when this is done, we must update the associated CSP guidance to stop requiring the script hash as part of the CSP. |
Side-note for docs tracking: I'm going to let this PU issue track the work and not keep a docs repo issue on this given that it's an IF/WHEN scenario at this time. |
Assigning to @pavelsavara as #38721 resolves this issue. |
We will use dynamic |
Hmm, would that still fix this issue though as there's no inline script? Essentially, does the app run without errors with the following tag within the <meta http-equiv="Content-Security-Policy"
content="base-uri 'self';
block-all-mixed-content;
default-src 'self';
img-src data: https:;
object-src 'none';
script-src 'self'
'unsafe-eval';
style-src 'self';
upgrade-insecure-requests;"> |
Maybe I don't fully follow what is the issue/goal here. Could you please elaborate @TanayParikh ? |
@TanayParikh ... There's no repo issue here for the 7.0 Roadmap (yet), and it's not clear if this will make that roadmap when that issue is created. Don't we need a tracking issue on the docs side so that we don't forget to document this for 7.0? Note that we don't have the ability to pre-document 7.0 yet ... the ability to version content in docs for 7.0 will happen mid-year ... but we can have a docs issue on HOLD on the Blazor.Docs project so that we don't miss this when the time comes. |
Discussed with @pavelsavara offline. The issue here was we had an inline JS which is not permitted with the default CSP policy:
To allow this script without triggering CSP errors we added the script's hash to the CSP: With @pavelsavara's changes here: we no longer have the inline JS script, hence we also no longer need the script hash we added to the CSP. Thanks for pointing that out @guardrex, I've created dotnet/AspNetCore.Docs#24570 to ensure we update the docs accordingly for .NET 7 |
@TanayParikh This is cool, when will this be released? Is there a way to add a CSP nonce to all the Blazor js scripts after this change? It is easy to add this, if the Blazor js script is added in the index/host file, but if the script is created dynamically then I don't see how this can be added. Greetings Damien |
This'll be a part of .NET 7.
The purpose of this change is specifically to facilitate removing the inline JS script hash from the Blazor WASM CSP. I think you may be interested in #6001 for your use case. Feel free to leave a thumbs up and/or a comment in that issue with your details 😄 |
aspnetcore/src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts
Lines 201 to 215 in 5750125
The text was updated successfully, but these errors were encountered: