diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index e617d861..b8e8a585 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -2,165 +2,23 @@ netcoreapp2.1 - false + true + ..\Keys\Longbow.Utility.snk - + + - + - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Bootstrap.Admin/Program.cs b/Bootstrap.Admin/Program.cs index 3fbfa281..c3a06117 100644 --- a/Bootstrap.Admin/Program.cs +++ b/Bootstrap.Admin/Program.cs @@ -1,7 +1,5 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using System; namespace Bootstrap.Admin { @@ -9,13 +7,10 @@ namespace Bootstrap.Admin { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateWebHostBuilder(args).Build().Run(); } - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .ConfigureAppConfiguration(builder => builder.SetBasePath(AppContext.BaseDirectory).AddJsonFile("cache.json", true, true)) - .UseStartup() - .Build(); + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args).UseStartup(); } } diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index 2dfb5e76..3e05f423 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -12,6 +12,8 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; @@ -33,6 +35,12 @@ namespace Bootstrap.Admin // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.Configure(options => + { + // This lambda determines whether user consent for non-essential cookies is needed for a given request. + options.CheckConsentNeeded = context => true; + options.MinimumSameSitePolicy = SameSiteMode.None; + }); services.AddCors(); services.AddLogging(builder => builder.AddFileLogger().AddDBLogger(ExceptionHelper.Log)); services.AddConfigurationManager(); @@ -51,7 +59,7 @@ namespace Bootstrap.Admin options.SerializerSettings.ContractResolver = new DefaultContractResolver(); options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; JsonConvert.DefaultSettings = () => options.SerializerSettings; - }); + }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); } @@ -60,16 +68,18 @@ namespace Bootstrap.Admin { if (env.IsDevelopment()) { - app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } app.UseStatusCodePagesWithReExecute("/Home/Error/{0}"); app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials()); + app.UseHttpsRedirection(); app.UseStaticFiles(); + app.UseCookiePolicy(); app.UseAuthentication(); app.UseBootstrapRoleAuthorization(); app.UseWebSocketHandler();