Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Farther changes in App_settings
support65112346b99a
diff --git a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs b/src/Core/Grand.Infrastructure/Configuration/AppConfig.csindex f72336dba..6146c3352 100644--- a/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs+++ b/src/Core/Grand.Infrastructure/Configuration/AppConfig.cs@@ -43,7 +43,12 @@ namespace Grand.Infrastructure.Configurationpublic bool UseRequestLocalization { get; set; }public string DefaultRequestCulture { get; set; }public IList<string> SupportedCultures { get; set; }-++ /// <summary>+ /// Gets or sets a value custom response header encoding may be needed in some cases+ /// </summary>+ public bool AllowNonAsciiCharInHeaders { get; set; }+/// <summary>/// Gets or sets a value indicating - (Serilog) use middleware for smarter HTTP request logging/// </summary>diff --git a/src/Core/Grand.Infrastructure/Configuration/HostingConfig.cs b/src/Core/Grand.Infrastructure/Configuration/HostingConfig.csdeleted file mode 100644index 64b000f70..000000000--- a/src/Core/Grand.Infrastructure/Configuration/HostingConfig.cs+++ /dev/null@@ -1,21 +0,0 @@-namespace Grand.Infrastructure.Configuration-{- public partial class HostingConfig- {- /// <summary>- /// Gets or sets a value indicating whether to use Forwards proxied headers onto current request- /// </summary>- public bool UseForwardedHeaders { get; set; }-- /// <summary>- /// Gets or sets a value for allowedHosts, is used for host filtering to bind your app to specific hostnames- /// </summary>- public string AllowedHosts { get; set; }-- /// <summary>- /// Gets or sets a value custom response header encoding may be needed in some cases- /// </summary>- public bool AllowNonAsciiCharInHeaders { get; set; }-- }-}diff --git a/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs b/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.csindex ac78c1927..484641483 100644--- a/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs+++ b/src/Core/Grand.Infrastructure/Configuration/SecurityConfig.cs@@ -2,6 +2,16 @@{public partial class SecurityConfig{+ /// <summary>+ /// Gets or sets a value indicating whether to use Forwards proxied headers onto current request+ /// </summary>+ public bool UseForwardedHeaders { get; set; }++ /// <summary>+ /// Gets or sets a value for allowedHosts, is used for host filtering to bind your app to specific hostnames+ /// </summary>+ public string AllowedHosts { get; set; }+/// <summary>/// Gets or sets a value indicating for cookie expires in hours - default 24 * 365 = 8760/// </summary>diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex c57a021fa..69cac6c6c 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -194,7 +194,6 @@ namespace Grand.Infrastructurevar performanceConfig = services.StartupConfig<PerformanceConfig>(configuration.GetSection("Performance"));var securityConfig = services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));services.StartupConfig<ExtensionsConfig>(configuration.GetSection("Extensions"));- services.StartupConfig<HostingConfig>(configuration.GetSection("Hosting"));services.StartupConfig<UrlRewriteConfig>(configuration.GetSection("UrlRewrite"));services.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));services.StartupConfig<RabbitConfig>(configuration.GetSection("Rabbit"));diff --git a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.csindex 785ad501e..9306bc8c7 100644--- a/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs+++ b/src/Web/Grand.Web.Common/Startup/ForwardedHeadersStartup.cs@@ -33,9 +33,9 @@ namespace Grand.Web.Common.Startupreturn;var serviceProvider = application.ApplicationServices;- var hostingConfig = serviceProvider.GetRequiredService<HostingConfig>();+ var securityConfig = serviceProvider.GetRequiredService<SecurityConfig>();- if (hostingConfig.UseForwardedHeaders)+ if (securityConfig.UseForwardedHeaders)application.UseGrandForwardedHeaders();}diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.jsonindex 91a97f14c..fdadb6e72 100644--- a/src/Web/Grand.Web/App_Data/appsettings.json+++ b/src/Web/Grand.Web/App_Data/appsettings.json@@ -1,19 +1,9 @@{- "Hosting": {- //Use a reverse proxy server - more information you can find at: https://docs.microsoft.com/en-US/aspnet/core/host-and-deploy/linux-nginx- "UseForwardedHeaders": false,-- //AllowedHosts, is used for host filtering to bind your app to specific hostnames- "AllowedHosts": "",-- //Note: While use of custom response header encoding may be needed in some cases,- //we discourage the use of non-ASCII encodings to avoid compatibility issues with other HTTP clients.- "AllowNonAsciiCharInHeaders": false- },-"Application": {+//Enable if you want to see the full error in production environment. It's ignored (always enabled) in development environment"DisplayFullErrorStack": true,+//Value of "Cache-Control" header value for static content"StaticFilesCacheControl": "public,max-age=31536000",@@ -30,16 +20,28 @@//Use my request localization culture"UseRequestLocalization": false,"DefaultRequestCulture": "en-US",+ "SupportedCultures": [ "en-US", "pl-PL" ], //sample list- //sample list- "SupportedCultures": [ "en-US", "pl-PL" ],//Indicates whether to disable hosted service - BackgroundServiceTask"DisableHostedService": false,++ //Note: While use of custom response header encoding may be needed in some cases,+ //we discourage the use of non-ASCII encodings to avoid compatibility issues+ //with other HTTP clients.+ "AllowNonAsciiCharInHeaders": false,+//(Serilog) Request logging - The package includes middleware for smarter HTTP request logging."UseSerilogRequestLogging": false},"Security": {++ //Use a reverse proxy server - more information you can find at: https://docs.microsoft.com/en-US/aspnet/core/host-and-deploy/linux-nginx+ "UseForwardedHeaders": false,++ //AllowedHosts, is used for host filtering to bind your app to specific hostnames+ "AllowedHosts": "*",+//This settings adds the following headers to all responses that pass//X-Content-Type-Options: nosniff//Strict-Transport-Security: max-age=31536000; includeSubDomains@@ -71,22 +73,28 @@//This is the one you should be targeting if your production environment fully runs on HTTPS"CookieSecurePolicyAlways": false},+"Extensions": {//For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk///https://github.com/dotnet/roslyn/wiki/Roslyn-Overview"UseRoslynScripts": false,+//Disable upload extensions plugins/themes"DisableUploadExtensions": false,+//A list of plugins to be ignored during start application - pattern"PluginSkipLoadingPattern": "",+//Enable if you want to clear /Plugins/bin directory on application startup"ClearPluginShadowDirectoryOnStartup": true,+//For develop you should enable if you want to copy plugin dll files to directory /Plugins/bin on application startup"PluginShadowCopy": true-},+"Performance": {+//Flag for whether to enable html minification"UseHtmlMinification": false,"HtmlMinificationErrors": false,@@ -112,12 +120,15 @@//Indicates whether to ignore InstallUrlMiddleware"IgnoreInstallUrlMiddleware": false,- //Indicates whether to ignore DbVersionCheckMiddleware++ //Indicates whether to ignore DbVersionCheckMiddleware"IgnoreDbVersionCheckMiddleware": false,+//Indicates whether to ignore UsePoweredByMiddleware"IgnoreUsePoweredByMiddleware": false},+"Redis": {///Enable the Publish/Subscribe messaging with redis to manage memory cache on every server"RedisPubSubEnabled": false,@@ -147,6 +158,7 @@"UrlRedirectToHttpsPermanent": false},"Azure": {+//Enable "RunOnAzureWebApps" if you run on Windows Azure Web Apps"RunOnAzureWebApps": false,diff --git a/src/Web/Grand.Web/Program.cs b/src/Web/Grand.Web/Program.csindex 9078d975b..12698f14a 100644--- a/src/Web/Grand.Web/Program.cs+++ b/src/Web/Grand.Web/Program.cs@@ -42,7 +42,7 @@ Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(builder.ConfiguratGrand.Infrastructure.StartupBase.ConfigureServices(builder.Services, builder.Configuration);//Allow non ASCII chars in headers-var config = new HostingConfig();+var config = new AppConfig();builder.Configuration.GetSection("Application").Bind(config);if (config.AllowNonAsciiCharInHeaders){