diff --git a/VirtoCommerce.Platform.Core/PlatformConstants.cs b/VirtoCommerce.Platform.Core/PlatformConstants.cs index a0e7a8120..091b0af3f 100644 --- a/VirtoCommerce.Platform.Core/PlatformConstants.cs +++ b/VirtoCommerce.Platform.Core/PlatformConstants.cs @@ -125,7 +125,6 @@ public static class Setup ValueType = SettingValueType.ShortText, DefaultValue = null }; - public static SettingDescriptor SampleDataState = new SettingDescriptor { Name = "VirtoCommerce.SampleDataState", @@ -140,7 +139,6 @@ public static class Setup ValueType = SettingValueType.ShortText, DefaultValue = AutoInstallState.Undefined }; - public static SettingDescriptor ModulesAutoInstalled = new SettingDescriptor { Name = "VirtoCommerce.ModulesAutoInstalled", @@ -148,6 +146,15 @@ public static class Setup ValueType = SettingValueType.Boolean, DefaultValue = false }; + public static SettingDescriptor NonEditableUsers = new SettingDescriptor + { + Name = "VirtoCommerce.NonEditableUsers", + GroupName = "Platform|Setup", + ValueType = SettingValueType.ShortText, + DefaultValue = null, + RestartRequired = true + }; + public static IEnumerable AllSettings { get @@ -156,6 +163,7 @@ public static IEnumerable AllSettings yield return SampleDataState; yield return ModulesAutoInstallState; yield return ModulesAutoInstalled; + yield return NonEditableUsers; } } } diff --git a/VirtoCommerce.Platform.Web/Startup.cs b/VirtoCommerce.Platform.Web/Startup.cs index 4adbfa960..4703563ba 100644 --- a/VirtoCommerce.Platform.Web/Startup.cs +++ b/VirtoCommerce.Platform.Web/Startup.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Linq; using System.Net; @@ -30,6 +31,7 @@ using VirtoCommerce.Platform.Core.Jobs; using VirtoCommerce.Platform.Core.Modularity; using VirtoCommerce.Platform.Core.Security; +using VirtoCommerce.Platform.Core.Settings; using VirtoCommerce.Platform.Data.Extensions; using VirtoCommerce.Platform.Data.PushNotifications; using VirtoCommerce.Platform.Data.Repositories; @@ -143,10 +145,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddAuthentication().AddCookie(); - services.AddSecurityServices(options => - { - options.NonEditableUsers = new[] { "admin" }; - }); + services.AddSecurityServices(); services.AddIdentity(options => options.Stores.MaxLengthForKeys = 128) .AddEntityFrameworkStores() @@ -320,7 +319,7 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceCollection services, ISettingsManager settingManager, IOptions securityOptions) { if (env.IsDevelopment()) @@ -397,6 +396,9 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseDbTriggers(); //Register platform settings app.UsePlatformSettings(); + var nonEditableUsers = settingManager.GetValue(PlatformConstants.Settings.Setup.NonEditableUsers.Name, string.Empty); + securityOptions.Value.NonEditableUsers = nonEditableUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + app.UseModules(); //Register platform permissions app.UsePlatformPermissions();