Content Security Policy nonce configuration
In this section, you will learn how to add a Content Security Policy (CSP) nonce to scripts & styles injected by Engage.
How to set a nonce
public class HomeController : RenderController
{
private readonly IContentInjectionSecurityService _contentInjectionSecurityService;
public HomeController(
ILogger<RenderController> logger,
ICompositeViewEngine compositeViewEngine,
IUmbracoContextAccessor umbracoContextAccessor,
IContentInjectionSecurityService contentInjectionSecurityService) : base(logger, compositeViewEngine, umbracoContextAccessor)
{
_contentInjectionSecurityService = contentInjectionSecurityService;
}
public IActionResult Home()
{
_contentInjectionSecurityService.SetNonceForCurrentRequest("Your-Nonce-Here");
return base.Index();
}
}Usage
Last updated
Was this helpful?