From 8b94bbbb4fd8be3c985c0e51e9147c0a64a43ded Mon Sep 17 00:00:00 2001 From: Mark Downie Date: Sat, 29 Aug 2020 21:29:30 -0400 Subject: [PATCH 1/2] Added cookie consent support --- source/DasBlog All.sln | 2 +- source/DasBlog.Web.UI/Startup.cs | 25 ++++++++++++------- .../Themes/darkly/_Layout.cshtml | 2 ++ .../DasBlog.Web.UI/Themes/darkly/custom.css | 2 +- .../Themes/dasblog/_Layout.cshtml | 2 ++ .../DasBlog.Web.UI/Themes/dasblog/custom.css | 1 + .../Themes/fulcrum/_Layout.cshtml | 4 +++ .../Themes/journal/_Layout.cshtml | 2 ++ .../Themes/median/_Layout.cshtml | 4 +++ .../DasBlog.Web.UI/Themes/median/custom.css | 4 +++ .../Views/Shared/_CookieConsentPartial.cshtml | 25 +++++++++++++++++++ 11 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 source/DasBlog.Web.UI/Views/Shared/_CookieConsentPartial.cshtml diff --git a/source/DasBlog All.sln b/source/DasBlog All.sln index c70e4454..3e701f6f 100644 --- a/source/DasBlog All.sln +++ b/source/DasBlog All.sln @@ -26,7 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DasBlog.Services", "DasBlog EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DasBlog.Test.Integration", "DasBlog.Tests\DasBlog.Test.Integration\DasBlog.Test.Integration.csproj", "{48500D1A-9780-412B-81C1-9DD810FECCAE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DasBlog.CLI", "DasBlog.CLI\DasBlog.CLI.csproj", "{3DEF6C9E-293A-4E41-9CEC-3466E3EEC754}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DasBlog.CLI", "DasBlog.CLI\DasBlog.CLI.csproj", "{3DEF6C9E-293A-4E41-9CEC-3466E3EEC754}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/source/DasBlog.Web.UI/Startup.cs b/source/DasBlog.Web.UI/Startup.cs index 4a5678c2..75f278eb 100644 --- a/source/DasBlog.Web.UI/Startup.cs +++ b/source/DasBlog.Web.UI/Startup.cs @@ -4,7 +4,13 @@ using DasBlog.Managers.Interfaces; using DasBlog.Services.ActivityLogs; using DasBlog.Services.ConfigFile.Interfaces; +using DasBlog.Services; +using DasBlog.Services.ConfigFile; using DasBlog.Services.FileManagement; +using DasBlog.Services.FileManagement.Interfaces; +using DasBlog.Services.Scheduler; +using DasBlog.Services.Site; +using DasBlog.Services.Users; using DasBlog.Web.Identity; using DasBlog.Web.Settings; using DasBlog.Web.Mappers; @@ -14,6 +20,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Rewrite; @@ -21,21 +28,14 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Quartz; using System; using System.IO; using System.Linq; using System.Security.Principal; using System.Threading; using System.Threading.Tasks; -using DasBlog.Services.Site; -using DasBlog.Services.ConfigFile; -using DasBlog.Services.Users; -using DasBlog.Services; -using Microsoft.AspNetCore.HttpOverrides; -using DasBlog.Services.FileManagement.Interfaces; -using Microsoft.Extensions.Logging; -using Quartz; -using DasBlog.Services.Scheduler; namespace DasBlog.Web { @@ -226,6 +226,12 @@ public void ConfigureServices(IServiceCollection services) .AddControllersWithViews() .AddRazorRuntimeCompilation(); + services.Configure(options => + { + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = SameSiteMode.None; + }); + services.AddQuartz(q => { q.SchedulerId = "Scheduler-Core"; @@ -311,6 +317,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDasBlog app.UseForwardedHeaders(); app.UseStaticFiles(); + app.UseCookiePolicy(); app.UseStaticFiles(new StaticFileOptions() { diff --git a/source/DasBlog.Web.UI/Themes/darkly/_Layout.cshtml b/source/DasBlog.Web.UI/Themes/darkly/_Layout.cshtml index 3781da47..54706f3c 100644 --- a/source/DasBlog.Web.UI/Themes/darkly/_Layout.cshtml +++ b/source/DasBlog.Web.UI/Themes/darkly/_Layout.cshtml @@ -51,6 +51,8 @@
+ + @RenderBody()
diff --git a/source/DasBlog.Web.UI/Themes/darkly/custom.css b/source/DasBlog.Web.UI/Themes/darkly/custom.css index 7df8ce52..46737852 100644 --- a/source/DasBlog.Web.UI/Themes/darkly/custom.css +++ b/source/DasBlog.Web.UI/Themes/darkly/custom.css @@ -11080,7 +11080,7 @@ a.text-dark:hover, a.text-dark:focus { } .alert-info { - background-color: #3498DB + background-color: #00bc8c } .alert-warning { diff --git a/source/DasBlog.Web.UI/Themes/dasblog/_Layout.cshtml b/source/DasBlog.Web.UI/Themes/dasblog/_Layout.cshtml index fd08976e..f6de5fc7 100644 --- a/source/DasBlog.Web.UI/Themes/dasblog/_Layout.cshtml +++ b/source/DasBlog.Web.UI/Themes/dasblog/_Layout.cshtml @@ -54,6 +54,8 @@
+ + @RenderBody()
diff --git a/source/DasBlog.Web.UI/Themes/dasblog/custom.css b/source/DasBlog.Web.UI/Themes/dasblog/custom.css index 48aaa7ae..e91cbad0 100644 --- a/source/DasBlog.Web.UI/Themes/dasblog/custom.css +++ b/source/DasBlog.Web.UI/Themes/dasblog/custom.css @@ -39,3 +39,4 @@ width: 100%; height: 100%; } + diff --git a/source/DasBlog.Web.UI/Themes/fulcrum/_Layout.cshtml b/source/DasBlog.Web.UI/Themes/fulcrum/_Layout.cshtml index aeb60f48..65413534 100644 --- a/source/DasBlog.Web.UI/Themes/fulcrum/_Layout.cshtml +++ b/source/DasBlog.Web.UI/Themes/fulcrum/_Layout.cshtml @@ -53,7 +53,11 @@
+ + + @RenderBody() +