You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
6.3 KiB
161 lines
6.3 KiB
using LINGYUN.Abp.Account;
|
|
using LINGYUN.Abp.AspNetCore.HttpOverrides;
|
|
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper;
|
|
using LINGYUN.Abp.AuditLogging.Elasticsearch;
|
|
using LINGYUN.Abp.Authentication.QQ;
|
|
using LINGYUN.Abp.Authentication.WeChat;
|
|
using LINGYUN.Abp.Data.DbMigrator;
|
|
using LINGYUN.Abp.EventBus.CAP;
|
|
using LINGYUN.Abp.Identity.AspNetCore.Session;
|
|
using LINGYUN.Abp.Identity.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Identity.OrganizaztionUnits;
|
|
using LINGYUN.Abp.Identity.Session.AspNetCore;
|
|
using LINGYUN.Abp.Localization.CultureMap;
|
|
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
|
|
using LINGYUN.Abp.OpenIddict.AspNetCore.Session;
|
|
using LINGYUN.Abp.OpenIddict.LinkUser;
|
|
using LINGYUN.Abp.OpenIddict.Portal;
|
|
using LINGYUN.Abp.OpenIddict.Sms;
|
|
using LINGYUN.Abp.OpenIddict.WeChat;
|
|
using LINGYUN.Abp.OpenIddict.WeChat.Work;
|
|
using LINGYUN.Abp.Saas.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Serilog.Enrichers.Application;
|
|
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
|
|
using LINGYUN.Abp.Sms.Aliyun;
|
|
using LINGYUN.Platform.EntityFrameworkCore;
|
|
using LY.MicroService.AuthServer.EntityFrameworkCore;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Account.Web;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
|
|
using Volo.Abp.AspNetCore.Serilog;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.Caching.StackExchangeRedis;
|
|
using Volo.Abp.EntityFrameworkCore.MySQL;
|
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.OpenIddict.EntityFrameworkCore;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
using Volo.Abp.PermissionManagement.Identity;
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
|
|
|
namespace LY.MicroService.AuthServer;
|
|
|
|
[DependsOn(
|
|
typeof(AbpSerilogEnrichersApplicationModule),
|
|
typeof(AbpSerilogEnrichersUniqueIdModule),
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
typeof(AbpAccountWebOpenIddictModule),
|
|
typeof(AbpAccountApplicationModule),
|
|
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
|
|
typeof(AbpAutofacModule),
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
|
typeof(AbpEntityFrameworkCoreMySQLModule),
|
|
typeof(AbpIdentityEntityFrameworkCoreModule),
|
|
typeof(AbpIdentityApplicationModule),
|
|
typeof(AbpIdentityAspNetCoreSessionModule),
|
|
typeof(AbpOpenIddictAspNetCoreSessionModule),
|
|
typeof(AbpOpenIddictEntityFrameworkCoreModule),
|
|
typeof(AbpOpenIddictSmsModule),
|
|
typeof(AbpOpenIddictWeChatModule),
|
|
typeof(AbpOpenIddictLinkUserModule),
|
|
typeof(AbpOpenIddictPortalModule),
|
|
typeof(AbpOpenIddictWeChatWorkModule),
|
|
typeof(AbpAuthenticationQQModule),
|
|
typeof(AbpAuthenticationWeChatModule),
|
|
typeof(AbpIdentityOrganizaztionUnitsModule),
|
|
typeof(PlatformEntityFrameworkCoreModule),
|
|
typeof(AbpLocalizationManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementDomainIdentityModule),
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
|
|
typeof(AbpSaasEntityFrameworkCoreModule),
|
|
typeof(AuthServerMigrationsEntityFrameworkCoreModule),
|
|
typeof(AbpDataDbMigratorModule),
|
|
typeof(AbpAuditLoggingElasticsearchModule), // 放在 AbpIdentity 模块之后,避免被覆盖
|
|
typeof(AbpLocalizationCultureMapModule),
|
|
typeof(AbpAspNetCoreMvcWrapperModule),
|
|
typeof(AbpAspNetCoreHttpOverridesModule),
|
|
typeof(AbpCAPEventBusModule),
|
|
typeof(AbpAliyunSmsModule)
|
|
)]
|
|
public partial class AuthServerModule : AbpModule
|
|
{
|
|
private const string DefaultCorsPolicyName = "Default";
|
|
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
|
|
PreConfigureAuth();
|
|
PreConfigureFeature();
|
|
PreForwardedHeaders();
|
|
PreConfigureApp(configuration);
|
|
PreConfigureCAP(configuration);
|
|
PreConfigureCertificate(configuration, hostingEnvironment);
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
ConfigureDbContext();
|
|
ConfigureCaching(configuration);
|
|
ConfigureIdentity(configuration);
|
|
ConfigureVirtualFileSystem();
|
|
ConfigureFeatureManagement();
|
|
ConfigureLocalization();
|
|
ConfigureDataSeeder();
|
|
ConfigureUrls(configuration);
|
|
ConfigureTiming(configuration);
|
|
ConfigureAuditing(configuration);
|
|
ConfigureMultiTenancy(configuration);
|
|
ConfigureJsonSerializer(configuration);
|
|
ConfigureMvc(context.Services, configuration);
|
|
ConfigureCors(context.Services, configuration);
|
|
ConfigureOpenTelemetry(context.Services, configuration);
|
|
ConfigureDistributedLocking(context.Services, configuration);
|
|
ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment());
|
|
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment());
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
var env = context.GetEnvironment();
|
|
|
|
app.UseForwardedHeaders();
|
|
app.UseMapRequestLocalization();
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
else
|
|
{
|
|
// app.UseErrorPage();
|
|
app.UseHsts();
|
|
}
|
|
// app.UseHttpsRedirection();
|
|
app.UseCookiePolicy();
|
|
app.UseCorrelationId();
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseCors(DefaultCorsPolicyName);
|
|
app.UseAuthentication();
|
|
app.UseAbpOpenIddictValidation();
|
|
app.UseMultiTenancy();
|
|
app.UseAbpSession();
|
|
app.UseDynamicClaims();
|
|
app.UseAuthorization();
|
|
app.UseAuditing();
|
|
app.UseAbpSerilogEnrichers();
|
|
app.UseConfiguredEndpoints();
|
|
}
|
|
}
|
|
|