From 7c181b65cd32b7a7003206a93267a8b22bc1342b Mon Sep 17 00:00:00 2001 From: hishamco Date: Sat, 12 Jun 2021 00:18:57 +0300 Subject: [PATCH] Fix merge conflict --- .../OqtaneServiceCollectionExtensions.cs | 2 ++ Oqtane.Client/Program.cs | 16 ---------------- .../OqtaneServiceCollectionExtensions.cs | 16 +++++++++++++--- Oqtane.Server/Startup.cs | 6 ++---- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs b/Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs index e06b991e..40db5da5 100644 --- a/Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs +++ b/Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs @@ -45,6 +45,8 @@ namespace Microsoft.Extensions.DependencyInjection services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); return services; } diff --git a/Oqtane.Client/Program.cs b/Oqtane.Client/Program.cs index cbb1e60c..ff27f5c0 100644 --- a/Oqtane.Client/Program.cs +++ b/Oqtane.Client/Program.cs @@ -48,9 +48,6 @@ namespace Oqtane.Client // dynamically register module services RegisterModuleServices(assembly, builder.Services); - // dynamically register database providers - RegisterDatabaseProviders(assembly, builder.Services); - // register client startup services RegisterClientStartups(assembly, builder.Services); } @@ -126,19 +123,6 @@ namespace Oqtane.Client } } - private static void RegisterDatabaseProviders(Assembly assembly, IServiceCollection services) - { - var databaseTypes = assembly.GetInterfaces(); - foreach (var databaseType in databaseTypes) - { - if (databaseType.AssemblyQualifiedName != null) - { - var serviceType = Type.GetType("Oqtane.Interfaces.IDatabase, Oqtane.Shared"); - services.AddScoped(serviceType ?? databaseType, databaseType); - } - } - } - private static void RegisterClientStartups(Assembly assembly, IServiceCollection services) { var startUps = assembly.GetInstances(); diff --git a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs index 92bcb688..d939110b 100644 --- a/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs +++ b/Oqtane.Server/Extensions/OqtaneServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Net; using System.Net.Http; using System.Reflection; using System.Runtime.Loader; @@ -34,7 +35,6 @@ namespace Microsoft.Extensions.DependencyInjection public static IServiceCollection AddOqtaneDbContext(this IServiceCollection services) { - services.AddScoped(); services.AddDbContext(options => { }); services.AddDbContext(options => { }); @@ -62,6 +62,7 @@ namespace Microsoft.Extensions.DependencyInjection services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); return services; } @@ -96,6 +97,8 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + // obsolete - replaced by ITenantManager + services.AddTransient(); return services; } @@ -105,12 +108,19 @@ namespace Microsoft.Extensions.DependencyInjection services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = false; + options.Cookie.SameSite = SameSiteMode.Strict; + options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; options.Events.OnRedirectToLogin = context => { - context.Response.StatusCode = 401; - + context.Response.StatusCode = (int)HttpStatusCode.Forbidden; return Task.CompletedTask; }; + options.Events.OnRedirectToAccessDenied = context => + { + context.Response.StatusCode = (int)HttpStatusCode.Forbidden; + return Task.CompletedTask; + }; + options.Events.OnValidatePrincipal = PrincipalValidator.ValidateAsync; }); return services; diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index fec5fa6e..d1fa176f 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -56,6 +52,8 @@ namespace Oqtane // Register localization services services.AddLocalization(options => options.ResourcesPath = "Resources"); + services.AddOptions>().Bind(Configuration.GetSection(SettingKeys.AvailableDatabasesSection)); + services.AddServerSideBlazor() .AddCircuitOptions(options => {