From 659dfbcdc90603aa4c346ed3048ae61790d95ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 25 Jan 2022 17:48:37 +0300 Subject: [PATCH 1/3] Remove commented code --- .../EShopOnAbpSharedHostingModule.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/shared/EShopOnAbp.Shared.Hosting/EShopOnAbpSharedHostingModule.cs b/shared/EShopOnAbp.Shared.Hosting/EShopOnAbpSharedHostingModule.cs index 904fd810..89cdaad2 100644 --- a/shared/EShopOnAbp.Shared.Hosting/EShopOnAbpSharedHostingModule.cs +++ b/shared/EShopOnAbp.Shared.Hosting/EShopOnAbpSharedHostingModule.cs @@ -32,11 +32,6 @@ namespace EShopOnAbp.Shared.Hosting database.MappedConnections.Add("AbpIdentity"); database.MappedConnections.Add("AbpIdentityServer"); }); - // - // options.Databases.Configure("ProductService", database => - // { - // database.MappedConnections.Add("ProductService"); - // }); }); } } From 0453e1e53bb8f7e5b1cf0c3262a262ed1c22b65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 25 Jan 2022 19:10:11 +0300 Subject: [PATCH 2/3] Code format changes. --- .../EShopOnAbpAuthServerModule.cs | 23 +++++++++---------- .../EShopUserClaimsPrincipalFactory.cs | 12 +++++++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs index e8c43e61..3cd489bf 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs +++ b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs @@ -31,7 +31,6 @@ using Volo.Abp.Emailing; using Volo.Abp.EventBus.RabbitMq; using Volo.Abp.IdentityServer; using Volo.Abp.Modularity; -using Volo.Abp.MultiTenancy; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; @@ -68,7 +67,7 @@ namespace EShopOnAbp.AuthServer PreConfigure(builder => { - builder.AddSigningCredential(GetSigningCertificate(hostingEnvironment, configuration)); + builder.AddSigningCredential(GetSigningCertificate(hostingEnvironment)); }); } } @@ -189,7 +188,6 @@ namespace EShopOnAbp.AuthServer app.UseStaticFiles(); app.UseRouting(); app.UseCors(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseAbpSerilogEnrichers(); @@ -204,16 +202,13 @@ namespace EShopOnAbp.AuthServer options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAuditing(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } - private X509Certificate2 GetSigningCertificate(IWebHostEnvironment hostingEnv, IConfiguration configuration) + private X509Certificate2 GetSigningCertificate(IWebHostEnvironment hostingEnv) { - var fileName = "eshoponabp-authserver.pfx"; - var passPhrase = "780F3C11-0A96-40DE-B335-9848BE88C77D"; + const string fileName = "eshoponabp-authserver.pfx"; + const string passPhrase = "780F3C11-0A96-40DE-B335-9848BE88C77D"; var file = Path.Combine(hostingEnv.ContentRootPath, fileName); if (!File.Exists(file)) @@ -229,9 +224,13 @@ namespace EShopOnAbp.AuthServer SwaggerWithAuthConfigurationHelper.Configure( context: context, authority: configuration["AuthServer:Authority"], - scopes: new Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + scopes: new Dictionary { - {"AccountService", "Account Service API"}, + /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + "AccountService", + "Account Service API" + }, }, apiTitle: "Account Service API" ); diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopUserClaimsPrincipalFactory.cs b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopUserClaimsPrincipalFactory.cs index 24421034..d4368878 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopUserClaimsPrincipalFactory.cs +++ b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopUserClaimsPrincipalFactory.cs @@ -48,15 +48,16 @@ public class EShopUserClaimsPrincipalFactory : AbpUserClaimsPrincipalFactory public override async Task CreateAsync(IdentityUser user) { var principal = await base.CreateAsync(user); + if (HttpContext.Request.Cookies.ContainsKey(EShopConstants.AnonymousUserClaimName)) { HttpContext.Request.Cookies.TryGetValue(EShopConstants.AnonymousUserClaimName, out var anonymousUserId); - await _cache.SetAsync(user.Id, new AnonymousUserItem {AnonymousUserId = anonymousUserId}, options: new DistributedCacheEntryOptions() { AbsoluteExpiration = DateTimeOffset.UtcNow.AddSeconds(60) }); + _logger.LogInformation($"Cached anonymousUserId:{anonymousUserId}."); } @@ -68,8 +69,13 @@ public class EShopUserClaimsPrincipalFactory : AbpUserClaimsPrincipalFactory } _logger.LogInformation($"Retrieved anonymousUserId:{cachedItem.AnonymousUserId} from cache."); - principal.Identities.First() - .AddClaim(new Claim(EShopConstants.AnonymousUserClaimName, cachedItem.AnonymousUserId)); + + principal.Identities.First().AddClaim( + new Claim( + EShopConstants.AnonymousUserClaimName, + cachedItem.AnonymousUserId + ) + ); return principal; } From 351eb18f11e517617a6ea3a9a4390206d9dafd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 25 Jan 2022 19:18:01 +0300 Subject: [PATCH 3/3] Remove commented code. --- .../AnonymousUser/AnonymousUserViewComponent.cs | 3 +-- .../AdministrationServiceHttpApiHostModule.cs | 7 +------ .../BasketServiceHttpApiHostModule.cs | 7 +------ .../CatalogServiceHttpApiHostModule.cs | 9 ++------- .../IdentityServiceHttpApiHostModule.cs | 9 ++------- .../OrderingServiceHttpApiHostModule.cs | 7 +------ .../PaymentServiceHttpApiHostModule.cs | 8 +------- 7 files changed, 9 insertions(+), 41 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs index 570c6c01..4a1f4965 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/AnonymousUser/AnonymousUserViewComponent.cs @@ -1,5 +1,4 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs index c87c1594..c5f43b20 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs @@ -34,7 +34,6 @@ namespace EShopOnAbp.AdministrationService var configuration = context.Services.GetConfiguration(); JwtBearerConfigurationHelper.Configure(context, "AdministrationService"); - // SwaggerConfigurationHelper.Configure(context, "Administration Service API"); SwaggerWithAuthConfigurationHelper.Configure( context: context, @@ -80,7 +79,6 @@ namespace EShopOnAbp.AdministrationService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - //app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -92,10 +90,7 @@ namespace EShopOnAbp.AdministrationService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - //endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } public override void OnPostApplicationInitialization(ApplicationInitializationContext context) diff --git a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs index 1d6d2665..11c952cd 100644 --- a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs @@ -31,7 +31,6 @@ namespace EShopOnAbp.BasketService JwtBearerConfigurationHelper.Configure(context, "AdministrationService"); //TODO: Should be "BasketService", but didn't work :( - // SwaggerConfigurationHelper.Configure(context, "Basket Service API"); SwaggerWithAuthConfigurationHelper.Configure( context: context, @@ -91,7 +90,6 @@ namespace EShopOnAbp.BasketService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -106,10 +104,7 @@ namespace EShopOnAbp.BasketService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } } } \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs index 10579704..bf85fc02 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs @@ -31,8 +31,7 @@ namespace EShopOnAbp.CatalogService { var configuration = context.Services.GetConfiguration(); - JwtBearerConfigurationHelper.Configure(context, "CatalogService"); //TODO: Should be "CatalogService", but didn't work :( - // SwaggerConfigurationHelper.Configure(context, "Catalog Service API"); + JwtBearerConfigurationHelper.Configure(context, "CatalogService"); SwaggerWithAuthConfigurationHelper.Configure( context: context, @@ -99,7 +98,6 @@ namespace EShopOnAbp.CatalogService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -114,10 +112,7 @@ namespace EShopOnAbp.CatalogService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } public override void OnPostApplicationInitialization(ApplicationInitializationContext context) diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs index 44e5a01f..9885791f 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Cors; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; -using Volo.Abp.Data; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -32,7 +31,7 @@ namespace EShopOnAbp.IdentityService var hostingEnvironment = context.Services.GetHostingEnvironment(); JwtBearerConfigurationHelper.Configure(context, "IdentityService"); - // SwaggerConfigurationHelper.Configure(context, "Identity Service API"); + context.Services.AddCors(options => { options.AddDefaultPolicy(builder => @@ -78,7 +77,6 @@ namespace EShopOnAbp.IdentityService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -90,10 +88,7 @@ namespace EShopOnAbp.IdentityService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } public override void OnPostApplicationInitialization(ApplicationInitializationContext context) diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs index f8c8a419..9bf50492 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs @@ -25,7 +25,6 @@ namespace EShopOnAbp.OrderingService )] public class OrderingServiceHttpApiHostModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -88,7 +87,6 @@ namespace EShopOnAbp.OrderingService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -104,10 +102,7 @@ namespace EShopOnAbp.OrderingService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } public override void OnPostApplicationInitialization(ApplicationInitializationContext context) diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs index 5600ec82..0c0ba4ea 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs @@ -1,6 +1,5 @@ using EShopOnAbp.PaymentService.DbMigrations; using EShopOnAbp.PaymentService.EntityFrameworkCore; -using EShopOnAbp.PaymentService.PayPal; using EShopOnAbp.Shared.Hosting.AspNetCore; using EShopOnAbp.Shared.Hosting.Microservices; using Microsoft.AspNetCore.Builder; @@ -33,7 +32,6 @@ namespace EShopOnAbp.PaymentService var configuration = context.Services.GetConfiguration(); JwtBearerConfigurationHelper.Configure(context, "PaymentService"); - // SwaggerConfigurationHelper.Configure(context, "Payment Service API"); SwaggerWithAuthConfigurationHelper.Configure( context: context, @@ -80,7 +78,6 @@ namespace EShopOnAbp.PaymentService app.UseAbpRequestLocalization(); app.UseStaticFiles(); app.UseRouting(); - // app.UseHttpMetrics(); app.UseAuthentication(); app.UseAbpClaimsMap(); app.UseAuthorization(); @@ -95,10 +92,7 @@ namespace EShopOnAbp.PaymentService app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); - app.UseConfiguredEndpoints(endpoints => - { - // endpoints.MapMetrics(); - }); + app.UseConfiguredEndpoints(); } public override void OnPostApplicationInitialization(ApplicationInitializationContext context)