From 84cc16ece6191253bb8d1891bb6e10a3ff2245f7 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Wed, 26 Oct 2022 03:57:25 -0400 Subject: [PATCH] removed unnecessery usings --- .../EShopOnAbpPublicWebModule.cs | 24 ++++++++++--------- .../JwtBearerConfigurationHelper.cs | 1 - 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs index f231a383..b0078b9b 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs @@ -72,8 +72,6 @@ namespace EShopOnAbp.PublicWeb; typeof(CmskitServiceHttpApiClientModule), typeof(CmsKitDomainModule), typeof(CmsKitPublicWebModule) - - )] public class EShopOnAbpPublicWebModule : AbpModule { @@ -147,6 +145,7 @@ public class EShopOnAbpPublicWebModule : AbpModule options.ClientId = configuration["AuthServer:ClientId"]; options.MetadataAddress = configuration["AuthServer:MetaAddress"]; options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.ResponseType = OpenIdConnectResponseType.CodeIdToken; options.GetClaimsFromUserInfoEndpoint = true; options.Scope.Add("openid"); options.Scope.Add("profile"); @@ -154,17 +153,16 @@ public class EShopOnAbpPublicWebModule : AbpModule options.Scope.Add("phone"); options.Scope.Add("roles"); options.Scope.Add("offline_access"); - + options.Scope.Add("AdministrationService"); options.Scope.Add("BasketService"); options.Scope.Add("CatalogService"); options.Scope.Add("PaymentService"); options.Scope.Add("OrderingService"); options.Scope.Add("CmskitService"); - + options.SaveTokens = true; - //Token response type, will sometimes need to be changed to IdToken, depending on config. - options.ResponseType = OpenIdConnectResponseType.Code; + //SameSite is needed for Chrome/Firefox, as they will give http error 500 back, if not set to unspecified. // options.NonceCookie.SameSite = SameSiteMode.Unspecified; // options.CorrelationCookie.SameSite = SameSiteMode.Unspecified; @@ -175,7 +173,7 @@ public class EShopOnAbpPublicWebModule : AbpModule // RoleClaimType = ClaimTypes.Role, // ValidateIssuer = true // }; - + if (AbpClaimTypes.UserName != "preferred_username") { options.ClaimActions.MapJsonKey(AbpClaimTypes.UserName, "preferred_username"); @@ -194,18 +192,21 @@ public class EShopOnAbpPublicWebModule : AbpModule options.Events.OnRedirectToIdentityProvider = async ctx => { // Intercept the redirection so the browser navigates to the right URL in your host - ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') + "connect/authorize"; + ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') + + "connect/authorize"; if (previousOnRedirectToIdentityProvider != null) { await previousOnRedirectToIdentityProvider(ctx); } }; - var previousOnRedirectToIdentityProviderForSignOut = options.Events.OnRedirectToIdentityProviderForSignOut; + var previousOnRedirectToIdentityProviderForSignOut = + options.Events.OnRedirectToIdentityProviderForSignOut; options.Events.OnRedirectToIdentityProviderForSignOut = async ctx => { // Intercept the redirection for signout so the browser navigates to the right URL in your host - ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') + "connect/endsession"; + ctx.ProtocolMessage.IssuerAddress = configuration["AuthServer:Authority"].EnsureEndsWith('/') + + "connect/endsession"; if (previousOnRedirectToIdentityProviderForSignOut != null) { @@ -250,7 +251,8 @@ public class EShopOnAbpPublicWebModule : AbpModule private void ConfigureBasketHttpClient(ServiceConfigurationContext context) { context.Services.AddStaticHttpClientProxies( - typeof(BasketServiceContractsModule).Assembly, remoteServiceConfigurationName: BasketServiceConstants.RemoteServiceName + typeof(BasketServiceContractsModule).Assembly, + remoteServiceConfigurationName: BasketServiceConstants.RemoteServiceName ); Configure(options => diff --git a/shared/EShopOnAbp.Shared.Hosting.Microservices/JwtBearerConfigurationHelper.cs b/shared/EShopOnAbp.Shared.Hosting.Microservices/JwtBearerConfigurationHelper.cs index f87c63f4..b00229f1 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Microservices/JwtBearerConfigurationHelper.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Microservices/JwtBearerConfigurationHelper.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection; using System; -using Microsoft.IdentityModel.Tokens; using Volo.Abp.Modularity; namespace EShopOnAbp.Shared.Hosting.Microservices;