aspnetcore-security-headers
aspnetcore-security-headers copied to clipboard
Usage with a single page application
Can we use nonce's with a SPA application? We don't have any Razor view to modify to add the asp-add-nonce
tag, instead, we somehow need the library to take the static files built by Webpack and modify them at runtime to add the nonce tokens.
Is this something this library can do?
At the moment it can't, it only supports the tag helper approach :/
If I wanted to write my own function that hooked into the spa and rewrote the HTML to insert nonce, does this library export the functions I would need to call into to generate tags or are those hidden inside the library as private methods?
You can inject ICspNonceService where you need the nonce for the current request :)
It's registered by services.AddCsp().