diff --git a/EnvelopeGenerator.Web/Program.cs b/EnvelopeGenerator.Web/Program.cs index 0bce58cc..43450505 100644 --- a/EnvelopeGenerator.Web/Program.cs +++ b/EnvelopeGenerator.Web/Program.cs @@ -16,6 +16,7 @@ using EnvelopeGenerator.Web.Models; using DigitalData.Core.DTO; using System.Text.Encodings.Web; using Ganss.Xss; +using EnvelopeGenerator.Web; var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); logger.Info("Logging initialized!"); @@ -183,15 +184,12 @@ try } app.UseHttpsRedirection(); - app.UseStaticFiles(); var csp = config["Content-Security-Policy"]; if(csp is not null) - app.Use(async (context, next) => - { - context.Response.Headers.Add("Content-Security-Policy", csp); - await next(); - }); + app.UseCSPMiddleware(csp); + + app.UseStaticFiles(); app.UseCookiePolicy(); diff --git a/EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml b/EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml index c2fc03e7..001141d1 100644 --- a/EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml +++ b/EnvelopeGenerator.Web/Views/Home/EnvelopeLocked.cshtml @@ -1,4 +1,7 @@ @{ + var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string; +} +@{ ViewData["Title"] = "Dokument geschützt"; var userLanguage = ViewData["UserLanguage"] as string; var languages = ViewData["Languages"] as string[]; @@ -50,7 +53,7 @@ - } -
\ No newline at end of file diff --git a/EnvelopeGenerator.Web/Views/Shared/_CookieConsentPartial.cshtml b/EnvelopeGenerator.Web/Views/Shared/_CookieConsentPartial.cshtml index 96c526f5..6dfed5cf 100644 --- a/EnvelopeGenerator.Web/Views/Shared/_CookieConsentPartial.cshtml +++ b/EnvelopeGenerator.Web/Views/Shared/_CookieConsentPartial.cshtml @@ -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) { - + var props = @Html.Raw(serializedProps); + var cookieSettings = new BootstrapCookieConsentSettings(props) + } \ No newline at end of file diff --git a/EnvelopeGenerator.Web/Views/Shared/_Layout.cshtml b/EnvelopeGenerator.Web/Views/Shared/_Layout.cshtml index a0e917a0..40a6853f 100644 --- a/EnvelopeGenerator.Web/Views/Shared/_Layout.cshtml +++ b/EnvelopeGenerator.Web/Views/Shared/_Layout.cshtml @@ -29,4 +29,4 @@ @Html.AntiForgeryToken()