Browse Source

Merge pull request #72 from abpframework/gterdem/async_enhancement

Use async initialization methods and remove AsyncHelper usages in the module classes.
pull/73/head
Halil İbrahim Kalkan 5 years ago
committed by GitHub
parent
commit
b841f772c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 312
      apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs
  2. 298
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  3. 135
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs
  4. 165
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs
  5. 168
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs
  6. 156
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs
  7. 182
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs
  8. 155
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs
  9. 172
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs
  10. 161
      services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs

312
apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs

@ -34,206 +34,198 @@ using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
namespace EShopOnAbp.AuthServer
namespace EShopOnAbp.AuthServer;
[DependsOn(
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpEventBusRabbitMqModule),
typeof(AbpBackgroundJobsRabbitMqModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAccountApplicationModule),
typeof(EShopOnAbpSharedHostingAspNetCoreModule),
typeof(EShopOnAbpSharedLocalizationModule),
typeof(AdministrationServiceEntityFrameworkCoreModule),
typeof(IdentityServiceEntityFrameworkCoreModule)
)]
public class EShopOnAbpAuthServerModule : AbpModule
{
[DependsOn(
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpEventBusRabbitMqModule),
typeof(AbpBackgroundJobsRabbitMqModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAccountApplicationModule),
typeof(EShopOnAbpSharedHostingAspNetCoreModule),
typeof(EShopOnAbpSharedLocalizationModule),
typeof(AdministrationServiceEntityFrameworkCoreModule),
typeof(IdentityServiceEntityFrameworkCoreModule)
)]
public class EShopOnAbpAuthServerModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
if (!hostingEnvironment.IsDevelopment())
{
var configuration = context.Services.GetConfiguration();
PreConfigure<AbpIdentityServerBuilderOptions>(options =>
{
options.AddDeveloperSigningCredential = false;
});
var hostingEnvironment = context.Services.GetHostingEnvironment();
PreConfigure<IIdentityServerBuilder>(builder =>
{
builder.AddSigningCredential(GetSigningCertificate(hostingEnvironment));
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
if (!hostingEnvironment.IsDevelopment())
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureSwagger(context, configuration);
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "AccountService";
});
Configure<IdentityServerOptions>(options =>
PreConfigure<AbpIdentityServerBuilderOptions>(options =>
{
options.IssuerUri = configuration["App:SelfUrl"];
options.AddDeveloperSigningCredential = false;
});
Configure<AbpClaimsServiceOptions>(options =>
{
options.RequestedClaims.AddRange(new[]{
EShopConstants.AnonymousUserClaimName
});
});
Configure<AbpAuditingOptions>(options =>
PreConfigure<IIdentityServerBuilder>(builder =>
{
options.ApplicationName = "AuthServer";
builder.AddSigningCredential(GetSigningCertificate(hostingEnvironment));
});
}
}
Configure<AppUrlOptions>(options =>
public override void ConfigureServices(ServiceConfigurationContext context)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureSwagger(context, configuration);
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "AccountService";
});
Configure<AbpDistributedCacheOptions>(options =>
Configure<IdentityServerOptions>(options => { options.IssuerUri = configuration["App:SelfUrl"]; });
Configure<AbpClaimsServiceOptions>(options =>
{
options.RequestedClaims.AddRange(new[]
{
options.KeyPrefix = "EShopOnAbp:";
EShopConstants.AnonymousUserClaimName
});
});
Configure<AbpAuditingOptions>(options => { options.ApplicationName = "AuthServer"; });
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys")
.SetApplicationName("eShopOnAbp-AuthServer");
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "EShopOnAbp:"; });
context.Services.AddCors(options =>
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys")
.SetApplicationName("eShopOnAbp-AuthServer");
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
#if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<EShopOnAbpSharedLocalizationModule>(Path.Combine(hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}shared{Path.DirectorySeparatorChar}EShopOnAbp.Shared.Localization"));
});
}
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
if (hostingEnvironment.IsDevelopment())
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
app.Use(async (ctx, next) =>
Configure<AbpVirtualFileSystemOptions>(options =>
{
if (ctx.Request.Headers.ContainsKey("from-ingress"))
{
ctx.SetIdentityServerOrigin(configuration["App:SelfUrl"]);
}
await next();
options.FileSets.ReplaceEmbeddedByPhysical<EShopOnAbpSharedLocalizationModule>(Path.Combine(
hostingEnvironment.ContentRootPath,
$"..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}shared{Path.DirectorySeparatorChar}EShopOnAbp.Shared.Localization"));
});
}
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.UseAbpRequestLocalization();
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (!env.IsDevelopment())
app.Use(async (ctx, next) =>
{
if (ctx.Request.Headers.ContainsKey("from-ingress"))
{
app.UseErrorPage();
ctx.SetIdentityServerOrigin(configuration["App:SelfUrl"]);
}
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Account Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAuditing();
app.UseConfiguredEndpoints();
}
private X509Certificate2 GetSigningCertificate(IWebHostEnvironment hostingEnv)
await next();
});
if (env.IsDevelopment())
{
const string fileName = "eshoponabp-authserver.pfx";
const string passPhrase = "780F3C11-0A96-40DE-B335-9848BE88C77D";
var file = Path.Combine(hostingEnv.ContentRootPath, fileName);
app.UseDeveloperExceptionPage();
}
if (!File.Exists(file))
{
throw new FileNotFoundException($"Signing Certificate couldn't found: {file}");
}
app.UseAbpRequestLocalization();
return new X509Certificate2(file, passPhrase);
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Account Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAuditing();
app.UseConfiguredEndpoints();
}
private X509Certificate2 GetSigningCertificate(IWebHostEnvironment hostingEnv)
{
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))
{
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string>
throw new FileNotFoundException($"Signing Certificate couldn't found: {file}");
}
return new X509Certificate2(file, passPhrase);
}
private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
{
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string>
{
/* Requested scopes for authorization code request and descriptions for swagger UI only */
{
/* Requested scopes for authorization code request and descriptions for swagger UI only */
{
"AccountService",
"Account Service API"
},
"AccountService",
"Account Service API"
},
apiTitle: "Account Service API"
);
}
},
apiTitle: "Account Service API"
);
}
}

298
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs

@ -40,190 +40,172 @@ using EShopOnAbp.PublicWeb.PaymentMethods;
using EShopOnAbp.PaymentService.PaymentMethods;
using Microsoft.Extensions.Configuration;
namespace EShopOnAbp.PublicWeb
namespace EShopOnAbp.PublicWeb;
[DependsOn(
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEventBusRabbitMqModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAccountHttpApiClientModule),
typeof(EShopOnAbpSharedHostingAspNetCoreModule),
typeof(EShopOnAbpSharedLocalizationModule),
typeof(CatalogServiceHttpApiClientModule),
typeof(BasketServiceHttpApiClientModule),
typeof(OrderingServiceHttpApiClientModule),
typeof(AbpAspNetCoreSignalRModule),
typeof(PaymentServiceHttpApiClientModule),
typeof(AbpAutoMapperModule)
)]
public class EShopOnAbpPublicWebModule : AbpModule
{
[DependsOn(
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEventBusRabbitMqModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAccountHttpApiClientModule),
typeof(EShopOnAbpSharedHostingAspNetCoreModule),
typeof(EShopOnAbpSharedLocalizationModule),
typeof(CatalogServiceHttpApiClientModule),
typeof(BasketServiceHttpApiClientModule),
typeof(OrderingServiceHttpApiClientModule),
typeof(AbpAspNetCoreSignalRModule),
typeof(PaymentServiceHttpApiClientModule),
typeof(AbpAutoMapperModule)
)]
public class EShopOnAbpPublicWebModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(
typeof(EShopOnAbpResource),
typeof(EShopOnAbpPublicWebModule).Assembly
);
});
}
options.AddAssemblyResource(
typeof(EShopOnAbpResource),
typeof(EShopOnAbpPublicWebModule).Assembly
);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
context.Services.AddAutoMapperObjectMapper<EShopOnAbpPublicWebModule>();
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<EShopOnAbpPublicWebModule>(validate: true); });
public override void ConfigureServices(ServiceConfigurationContext context)
Configure<AbpBundlingOptions>(options =>
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global,
bundle => { bundle.AddContributors(typeof(CartWidgetStyleContributor)); }
);
});
context.Services.AddAutoMapperObjectMapper<EShopOnAbpPublicWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<EShopOnAbpPublicWebModule>(validate: true);
});
Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = true; });
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddContributors(typeof(CartWidgetStyleContributor));
}
);
});
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "EShopOnAbp:"; });
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = true;
});
Configure<AppUrlOptions>(options => { options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; });
Configure<AbpDistributedCacheOptions>(options =>
{
options.KeyPrefix = "EShopOnAbp:";
});
ConfigurePayment(configuration);
Configure<AppUrlOptions>(options =>
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options => { options.ExpireTimeSpan = TimeSpan.FromDays(365); })
.AddAbpOpenIdConnect("oidc", options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("AccountService");
options.Scope.Add("AdministrationService");
options.Scope.Add("BasketService");
options.Scope.Add("CatalogService");
options.Scope.Add("PaymentService");
options.Scope.Add("OrderingService");
});
ConfigurePayment(configuration);
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
})
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("AccountService");
options.Scope.Add("AdministrationService");
options.Scope.Add("BasketService");
options.Scope.Add("CatalogService");
options.Scope.Add("PaymentService");
options.Scope.Add("OrderingService");
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys")
.SetApplicationName("eShopOnAbp-PublicWeb");
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys")
.SetApplicationName("eShopOnAbp-PublicWeb");
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new EShopOnAbpPublicWebMenuContributor(configuration));
});
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new EShopOnAbpPublicWebMenuContributor(configuration));
});
Configure<AbpToolbarOptions>(options =>
{
options.Contributors.Add(new EShopOnAbpPublicWebToolbarContributor());
});
Configure<AbpToolbarOptions>(options =>
context.Services
.AddReverseProxy()
.LoadFromConfig(configuration.GetSection("ReverseProxy"))
.AddTransforms(builderContext =>
{
options.Contributors.Add(new EShopOnAbpPublicWebToolbarContributor());
});
context.Services
.AddReverseProxy()
.LoadFromConfig(configuration.GetSection("ReverseProxy"))
.AddTransforms(builderContext =>
builderContext.AddRequestTransform(async (transformContext) =>
{
builderContext.AddRequestTransform(async (transformContext) =>
{
transformContext.ProxyRequest.Headers
.Authorization = new AuthenticationHeaderValue(
"Bearer",
await transformContext.HttpContext.GetTokenAsync("access_token")
);
});
transformContext.ProxyRequest.Headers
.Authorization = new AuthenticationHeaderValue(
"Bearer",
await transformContext.HttpContext.GetTokenAsync("access_token")
);
});
}
});
}
private void ConfigurePayment(IConfiguration configuration)
private void ConfigurePayment(IConfiguration configuration)
{
Configure<EShopOnAbpPublicWebPaymentOptions>(options =>
{
Configure<EShopOnAbpPublicWebPaymentOptions>(options =>
{
options.PaymentSuccessfulCallbackUrl = configuration["App:SelfUrl"].EnsureEndsWith('/') + "PaymentCompleted";
});
options.PaymentSuccessfulCallbackUrl =
configuration["App:SelfUrl"].EnsureEndsWith('/') + "PaymentCompleted";
});
Configure<PaymentMethodUiOptions>(options =>
{
options.ConfigureIcon(PaymentMethodNames.PayPal, "fa-cc-paypal paypal");
});
}
Configure<PaymentMethodUiOptions>(options =>
{
options.ConfigureIcon(PaymentMethodNames.PayPal, "fa-cc-paypal paypal");
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.Use((ctx, next) =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.Use((ctx, next) =>
{
ctx.Request.Scheme = "https";
return next();
});
ctx.Request.Scheme = "https";
return next();
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseAbpRequestLocalization();
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
// app.UseHttpMetrics();
app.UseAuthentication();
app.UseAbpSerilogEnrichers();
app.UseAuthorization();
app.UseConfiguredEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
// endpoints.MapMetrics();
});
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
// app.UseHttpMetrics();
app.UseAuthentication();
app.UseAbpSerilogEnrichers();
app.UseAuthorization();
app.UseConfiguredEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
// endpoints.MapMetrics();
});
}
}
}

135
gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs

@ -1,5 +1,4 @@
using System;
using EShopOnAbp.Shared.Hosting.Gateways;
using EShopOnAbp.Shared.Hosting.Gateways;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -8,84 +7,82 @@ using Ocelot.Middleware;
using System.Collections.Generic;
using System.Linq;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Cors;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace EShopOnAbp.WebPublicGateway
namespace EShopOnAbp.WebPublicGateway;
[DependsOn(
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class EShopOnAbpWebPublicGatewayModule : AbpModule
{
[DependsOn(
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class EShopOnAbpWebPublicGatewayModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{ "AccountService", "Account Service API" },
{ "IdentityService", "Identity Service API" },
{ "AdministrationService", "Administration Service API" },
{ "CatalogService", "Catalog Service API" },
{ "BasketService", "Basket Service API" },
{ "PaymentService", "Payment Service API" },
{ "OrderingService", "Ordering Service API" },
},
apiTitle: "WebPublic Gateway"
);
}
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{ "AccountService", "Account Service API" },
{ "IdentityService", "Identity Service API" },
{ "AdministrationService", "Administration Service API" },
{ "CatalogService", "Catalog Service API" },
{ "BasketService", "Basket Service API" },
{ "PaymentService", "Payment Service API" },
{ "OrderingService", "Ordering Service API" },
},
apiTitle: "WebPublic Gateway"
);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseAbpSerilogEnrichers();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
var routedServices = routes
.GroupBy(t => t.ServiceKey)
.Select(r => r.First())
.Distinct();
app.UseCorrelationId();
app.UseAbpSerilogEnrichers();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
var routedServices = routes
.GroupBy(t => t.ServiceKey)
.Select(r => r.First())
.Distinct();
foreach (var config in routedServices)
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
if (!env.IsDevelopment())
{
url = $"https://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}";
}
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}
});
app.MapWhen(
ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""),
app2 =>
foreach (var config in routedServices)
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
if (!env.IsDevelopment())
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
url = $"https://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}";
}
);
app.UseOcelot().Wait();
}
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}
});
app.MapWhen(
ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""),
app2 =>
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
}
);
app.UseOcelot().Wait();
}
}

165
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

@ -9,104 +9,103 @@ using System;
using System.Collections.Generic;
using System.Linq;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Microsoft.OpenApi.Models;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace EShopOnAbp.WebGateway
{
[DependsOn(
namespace EShopOnAbp.WebGateway;
[DependsOn(
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class EShopOnAbpWebGatewayModule : AbpModule
public class EShopOnAbpWebGatewayModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{ "AccountService", "Account Service API" },
{ "IdentityService", "Identity Service API" },
{ "AdministrationService", "Administration Service API" },
{ "CatalogService", "Catalog Service API" },
{ "BasketService", "Basket Service API" },
{ "PaymentService", "Payment Service API" },
{ "OrderingService", "Ordering Service API" },
{"AccountService", "Account Service API"},
{"IdentityService", "Identity Service API"},
{"AdministrationService", "Administration Service API"},
{"CatalogService", "Catalog Service API"},
{"BasketService", "Basket Service API"},
{"PaymentService", "Payment Service API"},
{"OrderingService", "Ordering Service API"},
},
apiTitle: "Web Gateway"
);
context.Services.AddCors(options =>
apiTitle: "Web Gateway"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
}
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.UseDeveloperExceptionPage();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseAbpSerilogEnrichers();
app.UseCors();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
var routedServices = routes
.GroupBy(t => t.ServiceKey)
.Select(r => r.First())
.Distinct();
app.UseCorrelationId();
app.UseAbpSerilogEnrichers();
app.UseCors();
app.UseSwagger();
app.UseSwaggerUI(options =>
foreach (var config in routedServices)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var routes = configuration.GetSection("Routes").Get<List<OcelotConfiguration>>();
var routedServices = routes
.GroupBy(t => t.ServiceKey)
.Select(r => r.First())
.Distinct();
foreach (var config in routedServices)
{
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
if (!env.IsDevelopment())
{
url = $"https://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}";
}
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}
});
app.MapWhen(
ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""),
app2 =>
var url =
$"{config.DownstreamScheme}://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}:{config.DownstreamHostAndPorts.FirstOrDefault()?.Port}";
if (!env.IsDevelopment())
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
url = $"https://{config.DownstreamHostAndPorts.FirstOrDefault()?.Host}";
}
);
app.UseOcelot().Wait();
}
options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}
});
app.MapWhen(
ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""),
app2 =>
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
}
);
app.UseOcelot().Wait();
}
}
}

168
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.AdministrationService.DbMigrations;
using EShopOnAbp.AdministrationService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
@ -17,104 +18,97 @@ using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.AdministrationService
namespace EShopOnAbp.AdministrationService;
[DependsOn(
typeof(AdministrationServiceHttpApiModule),
typeof(AdministrationServiceApplicationModule),
typeof(AdministrationServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpIdentityHttpApiClientModule)
)]
public class AdministrationServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(AdministrationServiceHttpApiModule),
typeof(AdministrationServiceApplicationModule),
typeof(AdministrationServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpIdentityHttpApiClientModule)
)]
public class AdministrationServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "AdministrationService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "AdministrationService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"AdministrationService", "Administration Service API"},
{"AdministrationService", "Administration Service API"}
},
apiTitle: "Administration Service API"
);
context.Services.AddCors(options =>
apiTitle: "Administration Service API"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
});
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(
() => scope.ServiceProvider
.GetRequiredService<AdministrationServiceDatabaseMigrationChecker>()
.CheckAsync()
);
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
//Log.Information("Sending event...");
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider
.GetRequiredService<AdministrationServiceDatabaseMigrationChecker>()
.CheckAsync();
}
//AsyncHelper.RunSync(
// () => scope.ServiceProvider
// .GetRequiredService<IDistributedEventBus>()
// .PublishAsync(new TenantCreatedEto { Id = Guid.Empty, Name = "Sample" })
// );
}
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context));
}
}
}

156
services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs

@ -13,98 +13,96 @@ using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Modularity;
namespace EShopOnAbp.BasketService
namespace EShopOnAbp.BasketService;
[DependsOn(
typeof(BasketServiceHttpApiModule),
typeof(BasketServiceApplicationModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class BasketServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(BasketServiceHttpApiModule),
typeof(BasketServiceApplicationModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class BasketServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
JwtBearerConfigurationHelper.Configure(context,
"AdministrationService"); //TODO: Should be "BasketService", but didn't work :(
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"BasketService", "Catalog Service API"},
},
apiTitle: "Basket Service API"
);
JwtBearerConfigurationHelper.Configure(context, "BasketService");
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
{"BasketService", "Basket Service API"}
},
apiTitle: "Basket Service API"
);
Configure<AbpAspNetCoreMvcOptions>(options =>
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.ConventionalControllers.Create(
typeof(BasketServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "basket";
opts.RemoteServiceName = "Basket";
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; });
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
Configure<AbpAspNetCoreMvcOptions>(options =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
options.ConventionalControllers.Create(
typeof(BasketServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "basket";
opts.RemoteServiceName = "Basket";
});
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; });
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
}

182
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs

@ -8,6 +8,7 @@ using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.MongoDB;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
@ -17,114 +18,111 @@ using Volo.Abp.Modularity;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace EShopOnAbp.CatalogService
namespace EShopOnAbp.CatalogService;
[DependsOn(
typeof(CatalogServiceHttpApiModule),
typeof(CatalogServiceApplicationModule),
typeof(CatalogServiceMongoDbModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class CatalogServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(CatalogServiceHttpApiModule),
typeof(CatalogServiceApplicationModule),
typeof(CatalogServiceMongoDbModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class CatalogServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "CatalogService");
JwtBearerConfigurationHelper.Configure(context, "CatalogService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"CatalogService", "Catalog Service API"},
{"CatalogService", "Catalog Service API"}
},
apiTitle: "Catalog Service API"
);
apiTitle: "Catalog Service API"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(CatalogServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "catalog";
opts.RemoteServiceName = "Catalog";
});
});
Configure<AbpUnitOfWorkDefaultOptions>(options =>
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
//Standalone MongoDB servers don't support transactions
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
Configure<AbpAntiForgeryOptions>(options =>
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(CatalogServiceApplicationModule).Assembly, opts =>
{
options.AutoValidate = false;
opts.RootPath = "catalog";
opts.RemoteServiceName = "Catalog";
});
}
});
public override void OnApplicationInitialization(ApplicationInitializationContext context)
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
//Standalone MongoDB servers don't support transactions
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; });
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
if (env.IsDevelopment())
{
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(
() => scope.ServiceProvider
.GetRequiredService<CatalogServiceDatabaseMigrationChecker>()
.CheckAsync()
);
}
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider
.GetRequiredService<CatalogServiceDatabaseMigrationChecker>()
.CheckAsync();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context));
}
}
}

155
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.IdentityService.DbMigrations;
using EShopOnAbp.IdentityService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
@ -15,96 +16,96 @@ using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.IdentityService
namespace EShopOnAbp.IdentityService;
[DependsOn(
typeof(EShopOnAbpSharedHostingMicroservicesModule),
typeof(IdentityServiceHttpApiModule),
typeof(IdentityServiceApplicationModule),
typeof(IdentityServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class IdentityServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(EShopOnAbpSharedHostingMicroservicesModule),
typeof(IdentityServiceHttpApiModule),
typeof(IdentityServiceApplicationModule),
typeof(IdentityServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class IdentityServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "IdentityService");
JwtBearerConfigurationHelper.Configure(context, "IdentityService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"IdentityService", "Identity Service API"}
},
apiTitle: "IdentityService Gateway API"
);
apiTitle: "IdentityService Gateway API"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
context.Services.AddCors(options =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
options.AddDefaultPolicy(builder =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
});
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(
() => scope.ServiceProvider
.GetRequiredService<IdentityServiceDatabaseMigrationChecker>()
.CheckAsync()
);
}
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider
.GetRequiredService<IdentityServiceDatabaseMigrationChecker>()
.CheckAsync();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context));
}
}

172
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs

@ -9,112 +9,112 @@ using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.OrderingService
namespace EShopOnAbp.OrderingService;
[DependsOn(
typeof(OrderingServiceHttpApiModule),
typeof(OrderingServiceApplicationModule),
typeof(OrderingServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class OrderingServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(OrderingServiceHttpApiModule),
typeof(OrderingServiceApplicationModule),
typeof(OrderingServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class OrderingServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
JwtBearerConfigurationHelper.Configure(context, "OrderingService");
JwtBearerConfigurationHelper.Configure(context, "OrderingService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"OrderingService", "Ordering Service API"},
{"OrderingService", "Ordering Service API"}
},
apiTitle: "Ordering Service API"
);
apiTitle: "Ordering Service API"
);
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
// TODO: Crate controller instead of auto-controller configuration
Configure<AbpAspNetCoreMvcOptions>(options =>
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.ConventionalControllers.Create(typeof(OrderingServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "ordering";
opts.RemoteServiceName = "Ordering";
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
}
});
public override void OnApplicationInitialization(ApplicationInitializationContext context)
// TODO: Crate controller instead of auto-controller configuration
Configure<AbpAspNetCoreMvcOptions>(options =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
options.ConventionalControllers.Create(typeof(OrderingServiceApplicationModule).Assembly, opts =>
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
opts.RootPath = "ordering";
opts.RemoteServiceName = "Ordering";
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
if (env.IsDevelopment())
{
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(
() => scope.ServiceProvider
.GetRequiredService<OrderingServiceDatabaseMigrationChecker>()
.CheckAsync()
);
}
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider
.GetRequiredService<OrderingServiceDatabaseMigrationChecker>()
.CheckAsync();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context));
}
}
}

161
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs

@ -9,102 +9,103 @@ using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.PaymentService
namespace EShopOnAbp.PaymentService;
[DependsOn(
typeof(PaymentServiceApplicationModule),
typeof(PaymentServiceEntityFrameworkCoreModule),
typeof(PaymentServiceHttpApiModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class PaymentServiceHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(PaymentServiceApplicationModule),
typeof(PaymentServiceEntityFrameworkCoreModule),
typeof(PaymentServiceHttpApiModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class PaymentServiceHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
JwtBearerConfigurationHelper.Configure(context, "PaymentService");
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
JwtBearerConfigurationHelper.Configure(context, "PaymentService");
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"PaymentService", "Payment Service API"},
{"PaymentService", "Payment Service API"}
},
apiTitle: "Payment Service API"
);
apiTitle: "Payment Service API"
);
context.Services.AddCors(options =>
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
});
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAbpClaimsMap();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(
() => scope.ServiceProvider
.GetRequiredService<PaymentServiceDatabaseMigrationChecker>()
.CheckAsync()
);
}
}
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.UseAuditing();
app.UseUnitOfWork();
app.UseConfiguredEndpoints();
}
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
{
await context.ServiceProvider
.GetRequiredService<PaymentServiceDatabaseMigrationChecker>()
.CheckAsync();
}
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context));
}
}
}
Loading…
Cancel
Save