feat: Add CSP configuration to use CSPMiddleware and CSP nonce to script tags in several cshtml script
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
@using DigitalData.Core.DTO;
|
||||
@{
|
||||
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
||||
}
|
||||
@using DigitalData.Core.DTO;
|
||||
@using Microsoft.AspNetCore.Http.Features
|
||||
@using Newtonsoft.Json.Serialization;
|
||||
@using Newtonsoft.Json;
|
||||
@@ -10,7 +13,7 @@
|
||||
}
|
||||
@if (showBanner)
|
||||
{
|
||||
<script>
|
||||
<script nonce="@nonce">
|
||||
@{
|
||||
var serializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
@@ -18,7 +21,7 @@
|
||||
};
|
||||
string serializedProps = JsonConvert.SerializeObject(_cookieSettings, serializerSettings);
|
||||
}
|
||||
var props = @Html.Raw(serializedProps);
|
||||
var cookieSettings = new BootstrapCookieConsentSettings(props)
|
||||
</script>
|
||||
var props = @Html.Raw(serializedProps);
|
||||
var cookieSettings = new BootstrapCookieConsentSettings(props)
|
||||
</script>
|
||||
}
|
||||
@@ -29,4 +29,4 @@
|
||||
</main>
|
||||
@Html.AntiForgeryToken()
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user