chore 调整nuget包版本
This commit is contained in:
@ -8,21 +8,6 @@
|
||||
<UserSecretsId>KonSoft.Payment-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.0.2" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Logs\**" />
|
||||
<Content Remove="Logs\**" />
|
||||
@ -34,6 +19,7 @@
|
||||
<ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.Application\KonSoft.Payment.Application.csproj" />
|
||||
<ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.EntityFrameworkCore\KonSoft.Payment.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\payment\src\KonSoft.Payment.HttpApi\KonSoft.Payment.HttpApi.csproj" />
|
||||
<ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,179 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Medallion.Threading;
|
||||
using Medallion.Threading.Redis;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using KonSoft.Payment.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using KonSoft.Payment.EntityFrameworkCore;
|
||||
using KonSoft.Payment.MultiTenancy;
|
||||
using StackExchange.Redis;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Serilog;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Caching.StackExchangeRedis;
|
||||
using Volo.Abp.DistributedLocking;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(PaymentApplicationModule),
|
||||
typeof(PaymentEntityFrameworkCoreModule),
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
)]
|
||||
public class PaymentHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
SwaggerConfigurationHelper.ConfigureWithOidc(
|
||||
context: context,
|
||||
authority: configuration["AuthServer:Authority"]!,
|
||||
scopes: ["PaymentService"],
|
||||
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
|
||||
apiTitle: "Payment Service API"
|
||||
);
|
||||
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Payment:"; });
|
||||
}
|
||||
|
||||
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
|
||||
{
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
if (hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
Configure<AbpVirtualFileSystemOptions>(options =>
|
||||
{
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<PaymentDomainSharedModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Payment.Domain.Shared"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<PaymentDomainModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Payment.Domain"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<PaymentApplicationContractsModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Payment.Application.Contracts"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<PaymentApplicationModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Payment.Application"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureConventionalControllers()
|
||||
{
|
||||
Configure<AbpAspNetCoreMvcOptions>(options =>
|
||||
{
|
||||
options.ConventionalControllers.Create(typeof(PaymentApplicationModule).Assembly);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddAbpJwtBearer(options =>
|
||||
{
|
||||
options.Authority = configuration["AuthServer:Authority"];
|
||||
options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata");
|
||||
options.Audience = "Payment";
|
||||
});
|
||||
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAbpSwaggerGenWithOAuth(
|
||||
configuration["AuthServer:Authority"]!,
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
{"Payment", "Payment API"}
|
||||
},
|
||||
options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Payment API", Version = "v1" });
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureDataProtection(
|
||||
ServiceConfigurationContext context,
|
||||
IConfiguration configuration,
|
||||
IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("Payment");
|
||||
if (!hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
|
||||
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "Payment-Protection-Keys");
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureDistributedLocking(
|
||||
ServiceConfigurationContext context,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
|
||||
{
|
||||
var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
|
||||
return new RedisDistributedSynchronizationProvider(connection.GetDatabase());
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(builder =>
|
||||
{
|
||||
builder
|
||||
.WithOrigins(configuration["App:CorsOrigins"]?
|
||||
.Split(",", StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(o => o.RemovePostFix("/"))
|
||||
.ToArray() ?? [])
|
||||
.WithAbpExposedHeaders()
|
||||
.SetIsOriginAllowedToAllowWildcardSubdomains()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
// ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
@ -193,7 +52,7 @@ public class PaymentHttpApiHostModule : AbpModule
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
if (KonSoftConsts.MultiTenancyEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user