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
Rename settings
supportd96017d56701
diff --git a/src/API/Grand.Api/Commands/Handlers/Common/GenerateTokenWebCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Common/GenerateTokenWebCommandHandler.csindex aae785666..7005c95b6 100644--- a/src/API/Grand.Api/Commands/Handlers/Common/GenerateTokenWebCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Common/GenerateTokenWebCommandHandler.cs@@ -8,25 +8,25 @@ namespace Grand.Api.Commands.Handlers.Common{public class GenerateTokenWebCommandHandler : IRequestHandler<GenerateTokenWebCommand, string>{- private readonly GrandWebApiConfig _grandWebApiConfig;+ private readonly FrontendAPIConfig _frontentApiConfig;- public GenerateTokenWebCommandHandler(GrandWebApiConfig grandWebApiConfig)+ public GenerateTokenWebCommandHandler(FrontendAPIConfig frontedApiConfig){- _grandWebApiConfig = grandWebApiConfig;+ _frontentApiConfig = frontedApiConfig;}public async Task<string> Handle(GenerateTokenWebCommand request, CancellationToken cancellationToken){var token = new JwtTokenBuilder();- token.AddSecurityKey(JwtSecurityKey.Create(_grandWebApiConfig.SecretKey));+ token.AddSecurityKey(JwtSecurityKey.Create(_frontentApiConfig.SecretKey));- if (_grandWebApiConfig.ValidateIssuer)- token.AddIssuer(_grandWebApiConfig.ValidIssuer);- if (_grandWebApiConfig.ValidateAudience)- token.AddAudience(_grandWebApiConfig.ValidAudience);+ if (_frontentApiConfig.ValidateIssuer)+ token.AddIssuer(_frontentApiConfig.ValidIssuer);+ if (_frontentApiConfig.ValidateAudience)+ token.AddAudience(_frontentApiConfig.ValidAudience);token.AddClaims(request.Claims);- token.AddExpiry(_grandWebApiConfig.ExpiryInMinutes);+ token.AddExpiry(_frontentApiConfig.ExpiryInMinutes);token.Build();return await Task.FromResult(token.Build().Value);diff --git a/src/API/Grand.Api/Controllers/TokenWebController.cs b/src/API/Grand.Api/Controllers/TokenWebController.csindex 246929582..054ba8a4e 100644--- a/src/API/Grand.Api/Controllers/TokenWebController.cs+++ b/src/API/Grand.Api/Controllers/TokenWebController.cs@@ -23,7 +23,7 @@ namespace Grand.Api.Controllersprivate readonly IRefreshTokenService _refreshTokenService;private readonly IUserFieldService _userFieldService;private readonly IAntiforgery _antiforgery;- private readonly GrandWebApiConfig _apiConfig;+ private readonly FrontendAPIConfig _apiConfig;public TokenWebController(ICustomerService customerService,@@ -32,7 +32,7 @@ namespace Grand.Api.ControllersIRefreshTokenService refreshTokenService,IUserFieldService userFieldService,IAntiforgery antiforgery,- GrandWebApiConfig apiConfig)+ FrontendAPIConfig apiConfig){_customerService = customerService;_mediator = mediator;diff --git a/src/API/Grand.Api/Infrastructure/ApiAuthenticationRegistrar.cs b/src/API/Grand.Api/Infrastructure/ApiAuthenticationRegistrar.csindex 16a38d2d9..7a54e6b26 100644--- a/src/API/Grand.Api/Infrastructure/ApiAuthenticationRegistrar.cs+++ b/src/API/Grand.Api/Infrastructure/ApiAuthenticationRegistrar.cs@@ -66,10 +66,10 @@ namespace Grand.Api.Infrastructure});- builder.AddJwtBearer(GrandWebApiConfig.Scheme, options =>+ builder.AddJwtBearer(FrontendAPIConfig.Scheme, options =>{- var config = new GrandWebApiConfig();- configuration.GetSection("GrandWebApi").Bind(config);+ var config = new FrontendAPIConfig();+ configuration.GetSection("FrontentAPI").Bind(config);options.TokenValidationParameters = new TokenValidationParameters {ValidateIssuer = config.ValidateIssuer,ValidateAudience = config.ValidateAudience,diff --git a/src/API/Grand.Api/Validators/Common/LoginWebValidator.cs b/src/API/Grand.Api/Validators/Common/LoginWebValidator.csindex b5fd8cbcd..ae3e3e0ad 100644--- a/src/API/Grand.Api/Validators/Common/LoginWebValidator.cs+++ b/src/API/Grand.Api/Validators/Common/LoginWebValidator.cs@@ -11,7 +11,7 @@ namespace Grand.Api.Validators.Common{public LoginWebValidator(IEnumerable<IValidatorConsumer<LoginWebModel>> validators,- GrandWebApiConfig apiConfig,+ FrontendAPIConfig apiConfig,ICustomerService customerService,ICustomerManagerService customerManagerService): base(validators)diff --git a/src/Business/Grand.Business.Authentication/Services/ApiAuthenticationService.cs b/src/Business/Grand.Business.Authentication/Services/ApiAuthenticationService.csindex 7f3aeaa99..1277af682 100644--- a/src/Business/Grand.Business.Authentication/Services/ApiAuthenticationService.cs+++ b/src/Business/Grand.Business.Authentication/Services/ApiAuthenticationService.cs@@ -79,7 +79,7 @@ namespace Grand.Business.Authentication.Servicesprivate async Task<Customer> ApiCustomer(){Customer customer = null;- var authResult = await _httpContextAccessor.HttpContext.AuthenticateAsync(GrandWebApiConfig.Scheme);+ var authResult = await _httpContextAccessor.HttpContext.AuthenticateAsync(FrontendAPIConfig.Scheme);if (!authResult.Succeeded){_httpContextAccessor.HttpContext.Response.StatusCode = 400;diff --git a/src/Business/Grand.Business.Authentication/Services/RefreshTokenService.cs b/src/Business/Grand.Business.Authentication/Services/RefreshTokenService.csindex bbdd97e5a..da374e335 100644--- a/src/Business/Grand.Business.Authentication/Services/RefreshTokenService.cs+++ b/src/Business/Grand.Business.Authentication/Services/RefreshTokenService.cs@@ -13,12 +13,12 @@ namespace Grand.Business.Authentication.Servicespublic class RefreshTokenService : IRefreshTokenService{private readonly IUserFieldService _userFieldService;- private readonly GrandWebApiConfig _grandWebApiConfig;+ private readonly FrontendAPIConfig _apiConfig;- public RefreshTokenService(IUserFieldService userFieldService, GrandWebApiConfig grandWebApiConfig)+ public RefreshTokenService(IUserFieldService userFieldService, FrontendAPIConfig apiConfig){_userFieldService = userFieldService;- _grandWebApiConfig = grandWebApiConfig;+ _apiConfig = apiConfig;}public string GenerateRefreshToken()@@ -37,7 +37,7 @@ namespace Grand.Business.Authentication.ServicesRefreshId=Guid.NewGuid().ToString(),Token = refreshToken,IsActive = true,- ValidTo = DateTime.UtcNow.AddMinutes(_grandWebApiConfig.RefreshTokenExpiryInMinutes)+ ValidTo = DateTime.UtcNow.AddMinutes(_apiConfig.RefreshTokenExpiryInMinutes)};await _userFieldService.SaveField(customer, SystemCustomerFieldNames.RefreshToken, token);return token;@@ -51,11 +51,11 @@ namespace Grand.Business.Authentication.Servicespublic ClaimsPrincipal GetPrincipalFromToken(string token){var tokenValidationParameters = new TokenValidationParameters {- ValidateAudience = _grandWebApiConfig.ValidateAudience,- ValidateIssuer = _grandWebApiConfig.ValidateIssuer,- ValidateIssuerSigningKey = _grandWebApiConfig.ValidateIssuerSigningKey,- IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_grandWebApiConfig.SecretKey)),- ValidateLifetime = _grandWebApiConfig.ValidateLifetime+ ValidateAudience = _apiConfig.ValidateAudience,+ ValidateIssuer = _apiConfig.ValidateIssuer,+ ValidateIssuerSigningKey = _apiConfig.ValidateIssuerSigningKey,+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(_apiConfig.SecretKey)),+ ValidateLifetime = _apiConfig.ValidateLifetime};var tokenHandler = new JwtSecurityTokenHandler();diff --git a/src/Core/Grand.Infrastructure/Configuration/GrandWebApiConfig.cs b/src/Core/Grand.Infrastructure/Configuration/FrontendAPIConfig.cssimilarity index 94%rename from src/Core/Grand.Infrastructure/Configuration/GrandWebApiConfig.csrename to src/Core/Grand.Infrastructure/Configuration/FrontendAPIConfig.csindex 1e1ff2d08..76369c380 100644--- a/src/Core/Grand.Infrastructure/Configuration/GrandWebApiConfig.cs+++ b/src/Core/Grand.Infrastructure/Configuration/FrontendAPIConfig.cs@@ -1,6 +1,6 @@namespace Grand.Infrastructure.Configuration{- public class GrandWebApiConfig+ public class FrontendAPIConfig{public static string Scheme => "GrandWebBearerScheme";public bool Enabled { get; set; }diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.csindex 2ddbdd174..04aeda9ac 100644--- a/src/Core/Grand.Infrastructure/StartupBase.cs+++ b/src/Core/Grand.Infrastructure/StartupBase.cs@@ -198,7 +198,7 @@ namespace Grand.Infrastructureservices.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));services.StartupConfig<RabbitConfig>(configuration.GetSection("Rabbit"));services.StartupConfig<ApiConfig>(configuration.GetSection("Api"));- services.StartupConfig<GrandWebApiConfig>(configuration.GetSection("GrandWebApi"));+ services.StartupConfig<FrontendAPIConfig>(configuration.GetSection("FrontendAPI"));services.StartupConfig<DatabaseConfig>(configuration.GetSection("Database"));services.StartupConfig<AmazonConfig>(configuration.GetSection("Amazon"));services.StartupConfig<AzureConfig>(configuration.GetSection("Azure"));diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.jsonindex d4ed03d69..ac0635e37 100644--- a/src/Web/Grand.Web/App_Data/appsettings.json+++ b/src/Web/Grand.Web/App_Data/appsettings.json@@ -200,7 +200,7 @@},//access to the api to web controllers- "GrandWebApi": {+ "FrontendAPI": {"Enabled": false,"SecretKey": "your private secret key", //at least 16 characters"ValidateIssuer": false,