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
Removed static property and applied SecurityConfig
support88f253de845b
diff --git a/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.csindex 719d1c2f2..3c86bd08a 100644--- a/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/CookieAuthenticationService.cs@@ -106,7 +106,7 @@ namespace Grand.Business.Authentication.Servicesvar authenticationProperties = new AuthenticationProperties {IsPersistent = isPersistent,IssuedUtc = DateTime.UtcNow,- ExpiresUtc = DateTime.UtcNow.AddHours(CommonHelper.CookieAuthExpires)+ ExpiresUtc = DateTime.UtcNow.AddHours(_securityConfig.CookieAuthExpires)};//sign in user@@ -216,7 +216,7 @@ namespace Grand.Business.Authentication.Services_httpContextAccessor.HttpContext.Response.Cookies.Delete(CustomerCookieName);//Get the date date of current cookie expiration- var cookieExpiresDate = DateTime.UtcNow.AddHours(CommonHelper.CookieAuthExpires);+ var cookieExpiresDate = DateTime.UtcNow.AddHours(_securityConfig.CookieAuthExpires);//If provided guid is empty (only remove cookies)if (customerGuid == Guid.Empty)diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex ba30857bf..4bcfd99fc 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -1,5 +1,4 @@using AutoMapper;-using FluentValidation;using Grand.Domain.Data;using Grand.Infrastructure.Caching.RabbitMq;using Grand.Infrastructure.Configuration;@@ -205,7 +204,7 @@ namespace Grand.Infrastructure//add AppConfig configuration parametersservices.StartupConfig<AppConfig>(configuration.GetSection("Application"));var performanceConfig = services.StartupConfig<PerformanceConfig>(configuration.GetSection("Performance"));- var securityConfig = services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));+ services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));services.StartupConfig<ExtensionsConfig>(configuration.GetSection("Extensions"));services.StartupConfig<CacheConfig>(configuration.GetSection("Cache"));services.StartupConfig<UrlRewriteConfig>(configuration.GetSection("UrlRewrite"));@@ -229,9 +228,7 @@ namespace Grand.InfrastructureCommonPath.WebHostEnvironment = hostingEnvironment.WebRootPath;CommonPath.BaseDirectory = hostingEnvironment.ContentRootPath;- CommonHelper.CookieAuthExpires =- securityConfig.CookieAuthExpires > 0 ? securityConfig.CookieAuthExpires : 24 * 365;-+CommonHelper.IgnoreAcl = performanceConfig.IgnoreAcl;CommonHelper.IgnoreStoreLimitations = performanceConfig.IgnoreStoreLimitations;diff --git a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.csindex 5b4c21ca8..d95ac50e8 100644--- a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs+++ b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs@@ -10,11 +10,6 @@ namespace Grand.SharedKernel.Extensions/// </summary>public static class CommonHelper{- /// <summary>- /// Gets or sets a value indicating for cookie expires in hours- /// </summary>- public static int CookieAuthExpires { get; set; }-/// <summary>/// Gets or sets a value indicating whether to ignore ACL rules (side-wide). It can significantly improve performance when enabled./// </summary>diff --git a/src/Web/Grand.Web.Common/StoreHelper.cs b/src/Web/Grand.Web.Common/StoreHelper.csindex 2e2e99bbc..1e2a2d879 100644--- a/src/Web/Grand.Web.Common/StoreHelper.cs+++ b/src/Web/Grand.Web.Common/StoreHelper.cs@@ -1,7 +1,7 @@using Grand.Business.Core.Interfaces.Common.Stores;using Grand.Domain.Stores;using Grand.Infrastructure;-using Grand.SharedKernel.Extensions;+using Grand.Infrastructure.Configuration;using Microsoft.AspNetCore.Http;namespace Grand.Web.Common@@ -12,7 +12,7 @@ namespace Grand.Web.Commonprivate readonly IHttpContextAccessor _httpContextAccessor;private readonly IStoreService _storeService;-+ private readonly SecurityConfig _securityConfig;private Store _cachedStore;private DomainHost _cachedDomainHost;@@ -24,10 +24,12 @@ namespace Grand.Web.Commonpublic StoreHelper(IHttpContextAccessor httpContextAccessor,- IStoreService storeService)+ IStoreService storeService,+ SecurityConfig securityConfig){_httpContextAccessor = httpContextAccessor;_storeService = storeService;+ _securityConfig = securityConfig;}#endregion@@ -133,7 +135,7 @@ namespace Grand.Web.Common_httpContextAccessor.HttpContext.Response.Cookies.Delete(StoreCookieName);//get date of cookie expiration- var cookieExpiresDate = DateTime.UtcNow.AddHours(CommonHelper.CookieAuthExpires);+ var cookieExpiresDate = DateTime.UtcNow.AddHours(_securityConfig.CookieAuthExpires);//set new cookie valuevar options = new CookieOptions {