Content Content Security Policy (CSP)
Implement a Content Security Policy (CSP) to protect your Umbraco site from XSS and data injection.
How to fix this health check
CSP nonces
Adding a CSP using custom middleware
using Umbraco.Cms.Core.Security;
app.Use(async (context, next) =>
{
ICspNonceService cspNonceService = context.RequestServices
.GetRequiredService<ICspNonceService>();
var nonce = cspNonceService.GetNonce();
context.Response.Headers.Append("Content-Security-Policy",
$"default-src 'self'; " +
$"script-src 'self' 'nonce-{nonce}'; " +
$"style-src 'self' 'unsafe-inline'; " +
$"img-src 'self' data: https://news-dashboard.umbraco.com; " +
$"connect-src 'self'; " +
$"font-src 'self'; " +
$"frame-src 'self' https://marketplace.umbraco.com");
await next();
});
app.UseUmbraco()...Adding a CSP using NWebsec
Last updated
Was this helpful?