diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs index 0a32e1904..496d98426 100644 --- a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs @@ -1,40 +1,45 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Serilog; -using Serilog.Events; - -namespace LY.MicroService.Applications.Single.DbMigrator; - -public class Program -{ - public async static Task Main(string[] args) - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) - .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) -#if DEBUG - .MinimumLevel.Override("LY.MicroService.Applications.Single.DbMigrator", LogEventLevel.Debug) -#else - .MinimumLevel.Override("LY.MicroService.Applications.Single.DbMigrator", LogEventLevel.Information) -#endif - .Enrich.FromLogContext() - .WriteTo.Console() - .WriteTo.File("Logs/migrations.txt") - .CreateLogger(); - - await CreateHostBuilder(args).RunConsoleAsync(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) - { - return Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureLogging((context, logging) => logging.ClearProviders()) - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); - } -} +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; + +namespace LY.MicroService.Applications.Single.DbMigrator; + +public class Program +{ + public async static Task Main(string[] args) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) +#if DEBUG + .MinimumLevel.Override("LY.MicroService.Applications.Single.DbMigrator", LogEventLevel.Debug) +#else + .MinimumLevel.Override("LY.MicroService.Applications.Single.DbMigrator", LogEventLevel.Information) +#endif + .Enrich.FromLogContext() + .WriteTo.Console() + .WriteTo.File("Logs/migrations.txt") + .CreateLogger(); + await CreateHostBuilder(args).RunConsoleAsync(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + // .ConfigureAppConfiguration((context, builder) => + // { + // builder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + // .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); + // } ) + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs index d9396a960..c9e26db0c 100644 --- a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs @@ -1,16 +1,24 @@ -using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; -using LY.MicroService.Applications.Single.EntityFrameworkCore; -using Volo.Abp.Autofac; -using Volo.Abp.Modularity; - -namespace LY.MicroService.Applications.Single.DbMigrator; - -[DependsOn( - typeof(AbpUINavigationVueVbenAdminModule), - typeof(SingleMigrationsEntityFrameworkCoreModule), - typeof(AbpAutofacModule) - )] -public partial class SingleDbMigratorModule : AbpModule -{ - -} +using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; +#if POSTGRESQL +using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql; +#else +using LY.MicroService.Applications.Single.EntityFrameworkCore; +#endif +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; + +namespace LY.MicroService.Applications.Single.DbMigrator; + +[DependsOn( + typeof(AbpUINavigationVueVbenAdminModule), +#if POSTGRESQL + typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule), +#else + typeof(SingleMigrationsEntityFrameworkCoreModule), +#endif + typeof(AbpAutofacModule) + )] +public partial class SingleDbMigratorModule : AbpModule +{ + +} diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json new file mode 100644 index 000000000..c18f8fec5 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json @@ -0,0 +1,245 @@ +{ + "App": { + "ShowPii": true, + "SelfUrl": "http://127.0.0.1:30001/", + "CorsOrigins": "http://127.0.0.1:3100,http://127.0.0.1:30001", + "Urls": { + "Applications": { + "MVC": { + "RootUrl": "http://127.0.0.1:30001/", + "Urls": { + "Abp.Account.EmailConfirm": "Account/EmailConfirm", + "Abp.Account.EmailVerifyLogin": "Account/VerifyCode" + } + }, + "STS": { + "RootUrl": "http://127.0.0.1:30001/" + }, + "VueVbenAdmin": { + "RootUrl": "http://127.0.0.1:3100", + "Urls": { + "Abp.Account.EmailConfirm": "account/email-confirm" + } + } + } + } + }, + "Auditing": { + "AllEntitiesSelector": true + }, + "DistributedCache": { + "HideErrors": true, + "KeyPrefix": "LINGYUN.Abp.Application", + "GlobalCacheEntryOptions": { + "SlidingExpiration": "30:00:00", + "AbsoluteExpirationRelativeToNow": "60:00:00" + } + }, + "ConnectionStrings": { + "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpAuditLogging": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpOpenIddict": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpIdentity": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpIdentityServer": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpSaas": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpTenantManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpFeatureManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpSettingManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpPermissionManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpLocalizationManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpTextTemplating": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AppPlatform": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "TaskManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Workflow": "Host=127.0.0.1;Database=Workflow-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Notifications": "Host=127.0.0.1;Database=Messages-V70;Username=postgres;Password=123456;SslMode=Prefer", + "MessageService": "Host=127.0.0.1;Database=Messages-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Demo": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer" + }, + "DistributedLock": { + "IsEnabled": true, + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=14" + } + }, + "Elsa": { + "Features": { + "DefaultPersistence": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + }, + "Console": true, + "Http": true, + "Email": true, + "TemporalQuartz": true, + "JavaScriptActivities": true, + "UserTask": true, + "Conductor": true, + "Telnyx": true, + "BlobStoring": true, + "Emailing": true, + "Notification": true, + "Sms": true, + "IM": true, + "PublishWebhook": true, + "Webhooks": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + }, + "WorkflowSettings": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + } + }, + "Server": { + "BaseUrl": "http://127.0.0.1:30000" + } + }, + "Quartz": { + "UsePersistentStore": false, + "Properties": { + "quartz.jobStore.dataSource": "tkm", + "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz", + "quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate, Quartz", + "quartz.dataSource.tkm.connectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;", + "quartz.dataSource.tkm.provider": "Npgsql", + "quartz.jobStore.clustered": "true", + "quartz.serializer.type": "json", + "quartz.dataSource.tkm.connectionStringName": "TaskManagement" + } + }, + "Redis": { + "IsEnabled": true, + "Configuration": "127.0.0.1,defaultDatabase=15", + "InstanceName": "LINGYUN.Abp.Application" + }, + "AuthServer": { + "UseOpenIddict": true, + "Authority": "http://127.0.0.1:30001/", + "ApiName": "lingyun-abp-application", + "SwaggerClientId": "InternalServiceClient", + "SwaggerClientSecret": "1q2w3E*" + }, + "IdentityServer": { + "Clients": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + }, + "InternalService": { + "ClientId": "InternalServiceClient" + } + } + }, + "OpenIddict": { + "Applications": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + }, + "InternalService": { + "ClientId": "InternalServiceClient" + } + }, + "Lifetime": { + "AuthorizationCode": "00:05:00", + "AccessToken": "14:00:00", + "DeviceCode": "00:10:00", + "IdentityToken": "00:20:00", + "RefreshToken": "14:00:00", + "RefreshTokenReuseLeeway": "00:00:30", + "UserCode": "00:10:00" + } + }, + "Identity": { + "Password": { + "RequiredLength": 6, + "RequiredUniqueChars": 0, + "RequireNonAlphanumeric": false, + "RequireLowercase": false, + "RequireUppercase": false, + "RequireDigit": false + }, + "Lockout": { + "AllowedForNewUsers": false, + "LockoutDuration": 5, + "MaxFailedAccessAttempts": 5 + }, + "SignIn": { + "RequireConfirmedEmail": false, + "RequireConfirmedPhoneNumber": false + } + }, + "FeatureManagement": { + "IsDynamicStoreEnabled": true + }, + "SettingManagement": { + "IsDynamicStoreEnabled": true + }, + "PermissionManagement": { + "IsDynamicStoreEnabled": true + }, + "TextTemplating": { + "IsDynamicStoreEnabled": true + }, + "WebhooksManagement": { + "IsDynamicStoreEnabled": true + }, + "Logging": { + "Serilog": { + "Elasticsearch": { + "IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" + } + } + }, + "AuditLogging": { + "Elasticsearch": { + "IndexPrefix": "abp.dev.auditing" + } + }, + "Elasticsearch": { + "NodeUris": "http://127.0.0.1:9200" + }, + "Serilog": { + "MinimumLevel": { + "Default": "Debug", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Debug" + } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "Elasticsearch", + "Args": { + "nodeUris": "http://127.0.0.1:9200", + "indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", + "autoRegisterTemplate": true, + "autoRegisterTemplateVersion": "ESv7" + } + } + ] + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj new file mode 100644 index 000000000..92608a503 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj @@ -0,0 +1,26 @@ + + + + + + + net8.0 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsDbContextFactory.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsDbContextFactory.cs new file mode 100644 index 000000000..e3495b1b7 --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsDbContextFactory.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; +using System.IO; + +namespace LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql; + +public class SingleMigrationsDbContextFactory : IDesignTimeDbContextFactory +{ + public SingleMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + var connectionString = configuration.GetConnectionString("Default"); + + var builder = new DbContextOptionsBuilder() + .UseNpgsql(connectionString, b => b.MigrationsAssembly("LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql")); + + return new SingleMigrationsDbContext(builder!.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../LY.MicroService.Applications.Single.DbMigrator/")) + .AddJsonFile("appsettings.json", optional: false) +#if POSTGRESQL + .AddJsonFile("appsettings.PostgreSql.json", optional: false) +#endif + .AddJsonFile("appsettings.Development.json", optional: true); + + return builder.Build(); + } +} diff --git a/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsEntityFrameworkCorePostgreSqlModule.cs b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsEntityFrameworkCorePostgreSqlModule.cs new file mode 100644 index 000000000..9c2b33f2a --- /dev/null +++ b/aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsEntityFrameworkCorePostgreSqlModule.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.PostgreSql; +using Volo.Abp.Modularity; + +namespace LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql; + +[DependsOn( + typeof(AbpEntityFrameworkCorePostgreSqlModule), + typeof(SingleMigrationsEntityFrameworkCoreModule) + )] +public class SingleMigrationsEntityFrameworkCorePostgreSqlModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(); + + Configure(options => + { + options.UseNpgsql(); + }); + } +} diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index d9d66bc79..4403f3493 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -1,933 +1,938 @@ -using Elsa; -using Elsa.Options; -using LINGYUN.Abp.Aliyun.Localization; -using LINGYUN.Abp.BackgroundTasks; -using LINGYUN.Abp.DataProtectionManagement; -using LINGYUN.Abp.Demo.Books; -using LINGYUN.Abp.Demo.Localization; -using LINGYUN.Abp.ExceptionHandling; -using LINGYUN.Abp.ExceptionHandling.Emailing; -using LINGYUN.Abp.Exporter.MiniExcel; -using LINGYUN.Abp.Idempotent; -using LINGYUN.Abp.Identity.Session; -using LINGYUN.Abp.IdentityServer.IdentityResources; -using LINGYUN.Abp.Localization.CultureMap; -using LINGYUN.Abp.Notifications; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; -using LINGYUN.Abp.OpenIddict.LinkUser; -using LINGYUN.Abp.OpenIddict.Permissions; -using LINGYUN.Abp.OpenIddict.Portal; -using LINGYUN.Abp.OpenIddict.Sms; -using LINGYUN.Abp.OpenIddict.WeChat; -using LINGYUN.Abp.Saas; -using LINGYUN.Abp.Serilog.Enrichers.Application; -using LINGYUN.Abp.Serilog.Enrichers.UniqueId; -using LINGYUN.Abp.Tencent.Localization; -using LINGYUN.Abp.TextTemplating; -using LINGYUN.Abp.WebhooksManagement; -using LINGYUN.Abp.WeChat.Common.Messages.Handlers; -using LINGYUN.Abp.WeChat.Localization; -using LINGYUN.Abp.WeChat.Work; -using LINGYUN.Abp.Wrapper; -using LINGYUN.Platform.Localization; -using LY.MicroService.Applications.Single.Authentication; -using LY.MicroService.Applications.Single.IdentityResources; -using Medallion.Threading; -using Medallion.Threading.Redis; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Cors; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.Extensions.Caching.StackExchangeRedis; -using Microsoft.IdentityModel.Logging; -using Microsoft.OpenApi.Models; -using MiniExcelLibs.Attributes; -using OpenIddict.Server; -using OpenIddict.Server.AspNetCore; -using Quartz; -using StackExchange.Redis; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; -using System.Text.Encodings.Web; -using System.Text.Unicode; -using Volo.Abp; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.AntiForgery; -using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -using Volo.Abp.Auditing; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.BlobStoring; -using Volo.Abp.BlobStoring.FileSystem; -using Volo.Abp.BlobStoring.Minio; -using Volo.Abp.Caching; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.FeatureManagement; -using Volo.Abp.Features; -using Volo.Abp.GlobalFeatures; -using Volo.Abp.Http.Client; -using Volo.Abp.Identity.Localization; -using Volo.Abp.IdentityServer; -using Volo.Abp.IdentityServer.Localization; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; -using Volo.Abp.Localization; -using Volo.Abp.MultiTenancy; -using Volo.Abp.OpenIddict; -using Volo.Abp.OpenIddict.Localization; -using Volo.Abp.PermissionManagement; -using Volo.Abp.Quartz; -using Volo.Abp.Security.Claims; -using Volo.Abp.SettingManagement; -using Volo.Abp.SettingManagement.Localization; -using Volo.Abp.Threading; -using Volo.Abp.UI.Navigation.Urls; -using Volo.Abp.VirtualFileSystem; -using VoloAbpExceptionHandlingOptions = Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingOptions; - -namespace LY.MicroService.Applications.Single; - -public partial class MicroServiceApplicationsSingleModule -{ - protected const string DefaultCorsPolicyName = "Default"; - public static string ApplicationName { get; set; } = "MicroService-Applications-Single"; - private readonly static OneTimeRunner OneTimeRunner = new(); - - private void PreConfigureFeature() - { - OneTimeRunner.Run(() => - { - GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); - }); - } - - private void PreConfigureApp(IConfiguration configuration) - { - AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; - - PreConfigure(options => - { - // 以开放端口区别,应在0-31之间 - options.SnowflakeIdOptions.WorkerId = 1; - options.SnowflakeIdOptions.WorkerIdBits = 5; - options.SnowflakeIdOptions.DatacenterId = 1; - }); - - if (configuration.GetValue("App:ShowPii")) - { - IdentityModelEventSource.ShowPII = true; - } - } - - private void PreConfigureAuthServer(IConfiguration configuration) - { - PreConfigure(builder => - { - builder.AddValidation(options => - { - //options.AddAudiences("lingyun-abp-application"); - - options.UseLocalServer(); - - options.UseAspNetCore(); - - options.UseDataProtection(); - }); - }); - } - - private void PreConfigureIdentity() - { - PreConfigure(builder => - { - builder.AddDefaultTokenProviders(); - }); - } - - private void PreConfigureCertificate(IConfiguration configuration, IWebHostEnvironment environment) - { - var cerConfig = configuration.GetSection("Certificates"); - if (environment.IsProduction() && cerConfig.Exists()) - { - // 开发环境下存在证书配置 - // 且证书文件存在则使用自定义的证书文件来启动Ids服务器 - var cerPath = Path.Combine(environment.ContentRootPath, cerConfig["CerPath"]); - if (File.Exists(cerPath)) - { - var certificate = new X509Certificate2(cerPath, cerConfig["Password"]); - - if (configuration.GetValue("AuthServer:UseOpenIddict")) - { - PreConfigure(options => - { - //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html - options.AddDevelopmentEncryptionAndSigningCertificate = false; - }); - - PreConfigure(builder => - { - builder.AddSigningCertificate(certificate); - builder.AddEncryptionCertificate(certificate); - - builder.UseDataProtection(); - - // 禁用https - builder.UseAspNetCore() - .DisableTransportSecurityRequirement(); - }); - } - else - { - PreConfigure(options => - { - options.AddDeveloperSigningCredential = false; - }); - - PreConfigure(builder => - { - builder.AddSigningCredential(certificate); - }); - } - } - } - else - { - if (configuration.GetValue("AuthServer:UseOpenIddict")) - { - PreConfigure(options => - { - //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html - options.AddDevelopmentEncryptionAndSigningCertificate = false; - }); - - PreConfigure(builder => - { - //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html - using (var algorithm = RSA.Create(keySizeInBits: 2048)) - { - var subject = new X500DistinguishedName("CN=Fabrikam Encryption Certificate"); - var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); - request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, critical: true)); - var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2)); - builder.AddSigningCertificate(certificate); - } - - using (var algorithm = RSA.Create(keySizeInBits: 2048)) - { - var subject = new X500DistinguishedName("CN=Fabrikam Signing Certificate"); - var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); - request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment, critical: true)); - var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2)); - builder.AddEncryptionCertificate(certificate); - } - - builder.UseDataProtection(); - - // 禁用https - builder.UseAspNetCore() - .DisableTransportSecurityRequirement(); - }); - } - } - } - - private void PreConfigureQuartz(IConfiguration configuration) - { - PreConfigure(options => - { - // 如果使用持久化存储, 则配置quartz持久层 - if (configuration.GetSection("Quartz:UsePersistentStore").Get()) - { - var settings = configuration.GetSection("Quartz:Properties").Get>(); - if (settings != null) - { - foreach (var setting in settings) - { - options.Properties[setting.Key] = setting.Value; - } - } - - options.Configurator += (config) => - { - config.UsePersistentStore(store => - { - store.UseProperties = false; - store.UseNewtonsoftJsonSerializer(); - }); - }; - } - }); - } - - private void PreConfigureElsa(IServiceCollection services, IConfiguration configuration) - { - var elsaSection = configuration.GetSection("Elsa"); - var startups = new[] - { - typeof(Elsa.Activities.Console.Startup), - typeof(Elsa.Activities.Http.Startup), - typeof(Elsa.Activities.UserTask.Startup), - typeof(Elsa.Activities.Temporal.Quartz.Startup), - typeof(Elsa.Activities.Email.Startup), - typeof(Elsa.Scripting.JavaScript.Startup), - typeof(Elsa.Activities.Webhooks.Startup), - }; - - PreConfigure(elsa => - { - elsa - .AddActivitiesFrom() - .AddWorkflowsFrom() - .AddFeatures(startups, configuration) - .ConfigureWorkflowChannels(options => elsaSection.GetSection("WorkflowChannels").Bind(options)); - - elsa.DistributedLockingOptionsBuilder - .UseProviderFactory(sp => name => - { - var provider = sp.GetRequiredService(); - - return provider.CreateLock(name); - }); - }); - - services.AddNotificationHandlersFrom(); - - PreConfigure(mvcBuilder => - { - mvcBuilder.AddApplicationPartIfNotExists(typeof(Elsa.Webhooks.Api.Endpoints.List).Assembly); - }); - } - - private void ConfigureAuthServer(IConfiguration configuration) - { - Configure(builder => - { - builder.DisableTransportSecurityRequirement(); - }); - - Configure(options => - { - options.DisableTransportSecurityRequirement = true; - }); - - Configure(options => - { - var lifetime = configuration.GetSection("OpenIddict:Lifetime"); - options.AuthorizationCodeLifetime = lifetime.GetValue("AuthorizationCode", options.AuthorizationCodeLifetime); - options.AccessTokenLifetime = lifetime.GetValue("AccessToken", options.AccessTokenLifetime); - options.DeviceCodeLifetime = lifetime.GetValue("DeviceCode", options.DeviceCodeLifetime); - options.IdentityTokenLifetime = lifetime.GetValue("IdentityToken", options.IdentityTokenLifetime); - options.RefreshTokenLifetime = lifetime.GetValue("RefreshToken", options.RefreshTokenLifetime); - options.RefreshTokenReuseLeeway = lifetime.GetValue("RefreshTokenReuseLeeway", options.RefreshTokenReuseLeeway); - options.UserCodeLifetime = lifetime.GetValue("UserCode", options.UserCodeLifetime); - }); - Configure(options => - { - options.PersistentSessionGrantTypes.Add(SmsTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(PortalTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(LinkUserTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.OfficialGrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.MiniProgramGrantType); - options.PersistentSessionGrantTypes.Add(AbpWeChatWorkGlobalConsts.GrantType); - }); - } - - private void ConfigureEndpoints(IServiceCollection services) - { - // 不需要 - //Configure(options => - //{ - // options.EndpointConfigureActions.Add( - // (context) => - // { - // context.Endpoints.MapFallbackToPage("/_Host"); - // }); - //}); - var preActions = services.GetPreConfigureActions(); - - services.AddAbpApiVersioning(options => - { - options.ReportApiVersions = true; - options.AssumeDefaultVersionWhenUnspecified = true; - - //options.ApiVersionReader = new HeaderApiVersionReader("api-version"); //Supports header too - //options.ApiVersionReader = new MediaTypeApiVersionReader(); //Supports accept header too - }, mvcOptions => - { - mvcOptions.ConfigureAbp(preActions.Configure()); - }); - - //services.AddApiVersioning(config => - //{ - // // Specify the default API Version as 1.0 - // config.DefaultApiVersion = new ApiVersion(1, 0); - // // Advertise the API versions supported for the particular endpoint (through 'api-supported-versions' response header which lists all available API versions for that endpoint) - // config.ReportApiVersions = true; - //}); - - //services.AddVersionedApiExplorer(options => - //{ - // // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service - // // note: the specified format code will format the version as "'v'major[.minor][-status]" - // options.GroupNameFormat = "'v'VVV"; - - // // note: this option is only necessary when versioning by url segment. the SubstitutionFormat - // // can also be used to control the format of the API version in route templates - // options.SubstituteApiVersionInUrl = true; - //}); - } - - private void ConfigureKestrelServer() - { - Configure(options => - { - options.Limits.MaxRequestBodySize = null; - options.Limits.MaxRequestBufferSize = null; - }); - } - - private void ConfigureBlobStoring(IConfiguration configuration) - { - Configure(options => - { - options.Containers.ConfigureAll((containerName, containerConfiguration) => - { - containerConfiguration.UseFileSystem(fileSystem => - { - fileSystem.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "blobs"); - }); - - //containerConfiguration.UseMinio(minio => - //{ - // configuration.GetSection("Minio").Bind(minio); - //}); - }); - }); - } - - private void ConfigureBackgroundTasks() - { - Configure(options => - { - options.NodeName = ApplicationName; - options.JobCleanEnabled = true; - options.JobFetchEnabled = true; - options.JobCheckEnabled = true; - }); - } - - private void ConfigureTextTemplating(IConfiguration configuration) - { - if (configuration.GetValue("TextTemplating:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicTemplateDefinitionStoreEnabled = true; - }); - } - } - - private void ConfigureFeatureManagement(IConfiguration configuration) - { - if (configuration.GetValue("FeatureManagement:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicFeatureStoreEnabled = true; - }); - } - Configure(options => - { - options.ProviderPolicies[EditionFeatureValueProvider.ProviderName] = AbpSaasPermissions.Editions.ManageFeatures; - options.ProviderPolicies[TenantFeatureValueProvider.ProviderName] = AbpSaasPermissions.Tenants.ManageFeatures; - }); - } - - private void ConfigureSettingManagement(IConfiguration configuration) - { - if (configuration.GetValue("SettingManagement:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicSettingStoreEnabled = true; - }); - } - } - - private void ConfigureWebhooksManagement(IConfiguration configuration) - { - if (configuration.GetValue("WebhooksManagement:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicWebhookStoreEnabled = true; - }); - } - } - /// - /// 配置数据导出 - /// - private void ConfigureExporter() - { - Configure(options => - { - options.MapExportSetting(typeof(BookDto), config => - { - config.DynamicColumns = new[] - { - // 忽略某些字段 - new DynamicExcelColumn(nameof(BookDto.AuthorId)){ Ignore = true }, - new DynamicExcelColumn(nameof(BookDto.LastModificationTime)){ Ignore = true }, - new DynamicExcelColumn(nameof(BookDto.LastModifierId)){ Ignore = true }, - new DynamicExcelColumn(nameof(BookDto.CreationTime)){ Ignore = true }, - new DynamicExcelColumn(nameof(BookDto.CreatorId)){ Ignore = true }, - new DynamicExcelColumn(nameof(BookDto.Id)){ Ignore = true }, - }; - }); - }); - } - /// - /// 配置数据权限 - /// - private void ConfigureEntityDataProtected() - { - Configure(options => - { - options.AddEntities(typeof(DemoResource), - new[] - { - typeof(Book), - }); - }); - } - - private void ConfigurePermissionManagement(IConfiguration configuration) - { - if (configuration.GetValue("PermissionManagement:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicPermissionStoreEnabled = true; - }); - } - Configure(options => - { - // Rename IdentityServer.Client.ManagePermissions - // See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs - options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpOpenIddictPermissions.Applications.ManagePermissions; - - //if (configuration.GetValue("AuthServer:UseOpenIddict")) - //{ - // options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpOpenIddictPermissions.Applications.ManagePermissions; - //} - //else - //{ - // options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpIdentityServerPermissions.Clients.ManagePermissions; - //} - }); - } - - private void ConfigureNotificationManagement(IConfiguration configuration) - { - if (configuration.GetValue("NotificationsManagement:IsDynamicStoreEnabled")) - { - Configure(options => - { - options.IsDynamicNotificationsStoreEnabled = true; - }); - } - } - - private void ConfigureDistributedLock(IServiceCollection services, IConfiguration configuration) - { - var distributedLockEnabled = configuration["DistributedLock:IsEnabled"]; - if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) - { - var redis = ConnectionMultiplexer.Connect(configuration["DistributedLock:Redis:Configuration"]); - services.AddSingleton(_ => new RedisDistributedSynchronizationProvider(redis.GetDatabase())); - } - } - - private void ConfigureVirtualFileSystem() - { - Configure(options => - { - options.FileSets.AddEmbedded("LY.MicroService.Applications.Single"); - }); - } - - private void ConfigureIdempotent() - { - Configure(options => - { - options.IsEnabled = true; - options.DefaultTimeout = 0; - }); - } - - private void ConfigureDbContext() - { - Configure(options => - { - options.UseMySQL(); - }); - } - - private void ConfigureDataSeeder() - { - Configure(options => - { - options.Resources.Add(new CustomIdentityResources.AvatarUrl()); - }); - } - - private void ConfigureExceptionHandling() - { - // 自定义需要处理的异常 - Configure(options => - { - // 加入需要处理的异常类型 - options.Handlers.Add(); - options.Handlers.Add(); - options.Handlers.Add(); - options.Handlers.Add(); - options.Handlers.Add(); - options.Handlers.Add(); - }); - // 自定义需要发送邮件通知的异常类型 - Configure(options => - { - // 是否发送堆栈信息 - options.SendStackTrace = true; - // 未指定异常接收者的默认接收邮件 - // 指定自己的邮件地址 - }); - - Configure(options => - { - options.SendStackTraceToClients = false; - options.SendExceptionsDetailsToClients = false; - }); - } - - private void ConfigureJsonSerializer(IConfiguration configuration) - { - // 统一时间日期格式 - Configure(options => - { - var jsonConfiguration = configuration.GetSection("Json"); - if (jsonConfiguration.Exists()) - { - jsonConfiguration.Bind(options); - } - }); - // 中文序列化的编码问题 - Configure(options => - { - options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); - }); - } - - private void ConfigureCaching(IConfiguration configuration) - { - Configure(options => - { - configuration.GetSection("DistributedCache").Bind(options); - }); - - Configure(options => - { - var redisConfig = ConfigurationOptions.Parse(options.Configuration); - options.ConfigurationOptions = redisConfig; - options.InstanceName = configuration["Redis:InstanceName"]; - }); - } - - private void ConfigureMultiTenancy(IConfiguration configuration) - { - // 多租户 - Configure(options => - { - options.IsEnabled = true; - }); - - var tenantResolveCfg = configuration.GetSection("App:Domains"); - if (tenantResolveCfg.Exists()) - { - Configure(options => - { - var domains = tenantResolveCfg.Get(); - foreach (var domain in domains) - { - options.AddDomainTenantResolver(domain); - } - }); - } - } - - private void ConfigureAuditing(IConfiguration configuration) - { - Configure(options => - { - options.ApplicationName = ApplicationName; - // 是否启用实体变更记录 - var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; - if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || - (bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) - { - options.EntityHistorySelectors.AddAllEntities(); - } - }); - } - - private void ConfigureSwagger(IServiceCollection services) - { - // Swagger - services.AddSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "App API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme - { - Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", - Name = "Authorization", - In = ParameterLocation.Header, - Scheme = "bearer", - Type = SecuritySchemeType.Http, - BearerFormat = "JWT" - }); - options.AddSecurityRequirement(new OpenApiSecurityRequirement - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } - }, - new string[] { } - } - }); - options.OperationFilter(); - }); - } - - private void ConfigureIdentity(IConfiguration configuration) - { - // 增加配置文件定义,在新建租户时需要 - Configure(options => - { - var identityConfiguration = configuration.GetSection("Identity"); - if (identityConfiguration.Exists()) - { - identityConfiguration.Bind(options); - } - }); - Configure(options => - { - options.IsDynamicClaimsEnabled = true; - }); - Configure(options => - { - options.IsCleanupEnabled = true; - }); - } - - private void ConfigureMvcUiTheme() - { - Configure(options => - { - //options.StyleBundles.Configure( - // LeptonXLiteThemeBundles.Styles.Global, - // bundle => - // { - // bundle.AddFiles("/global-styles.css"); - // } - //); - }); - } - - private void ConfigureLocalization() - { - Configure(options => - { - options.Languages.Add(new LanguageInfo("en", "en", "English")); - options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); - - options - .AddLanguagesMapOrUpdate( - "vue-admin-element-ui", - new NameValue("zh-Hans", "zh"), - new NameValue("en", "en")); - - // vben admin 语言映射 - options - .AddLanguagesMapOrUpdate( - "vben-admin-ui", - new NameValue("zh_CN", "zh-Hans")); - - options.Resources.Get() - .AddBaseTypes( - typeof(IdentityResource), - typeof(AliyunResource), - typeof(TencentCloudResource), - typeof(WeChatResource), - typeof(PlatformResource), - typeof(AbpOpenIddictResource), - typeof(AbpIdentityServerResource)); - - options.UseAllPersistence(); - }); - - Configure(options => - { - var zhHansCultureMapInfo = new CultureMapInfo - { - TargetCulture = "zh-Hans", - SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } - }; - - options.CulturesMaps.Add(zhHansCultureMapInfo); - options.UiCulturesMaps.Add(zhHansCultureMapInfo); - }); - } - - private void ConfigureWrapper() - { - Configure(options => - { - options.IsEnabled = true; - // options.IsWrapUnauthorizedEnabled = true; - options.IgnoreNamespaces.Add("Elsa"); - }); - } - - private void PreConfigureWrapper() - { - //PreConfigure(options => - //{ - // options.ProxyRequestActions.Add( - // (appid, httprequestmessage) => - // { - // httprequestmessage.Headers.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); - // }); - //}); - - PreConfigure(options => - { - options.ProxyClientActions.Add( - (_, _, client) => - { - client.DefaultRequestHeaders.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); - }); - }); - } - - private void ConfigureAuditing() - { - Configure(options => - { - // options.IsEnabledForGetRequests = true; - options.ApplicationName = ApplicationName; - }); - } - - private void ConfigureUrls(IConfiguration configuration) - { - Configure(options => - { - var applicationConfiguration = configuration.GetSection("App:Urls:Applications"); - foreach (var appConfig in applicationConfiguration.GetChildren()) - { - options.Applications[appConfig.Key].RootUrl = appConfig["RootUrl"]; - foreach (var urlsConfig in appConfig.GetSection("Urls").GetChildren()) - { - options.Applications[appConfig.Key].Urls[urlsConfig.Key] = urlsConfig.Value; - } - } - }); - } - - private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) - { - Configure(options => - { - options.AutoValidate = false; - }); - - services.Replace(ServiceLifetime.Scoped); - - services.AddAuthentication() - .AddAbpJwtBearer(options => - { - configuration.GetSection("AuthServer").Bind(options); - - options.Events ??= new JwtBearerEvents(); - options.Events.OnMessageReceived = context => - { - var accessToken = context.Request.Query["access_token"]; - var path = context.HttpContext.Request.Path; - if (!string.IsNullOrEmpty(accessToken) && - (path.StartsWithSegments("/api/files"))) - { - context.Token = accessToken; - } - return Task.CompletedTask; - }; - }); - - if (!isDevelopment) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - services - .AddDataProtection() - .SetApplicationName("LINGYUN.Abp.Application") - .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); - } - - services.AddSameSiteCookiePolicy(); - } - - private void ConfigureCors(IServiceCollection services, IConfiguration configuration) - { - services.AddCors(options => - { - options.AddPolicy(DefaultCorsPolicyName, builder => - { - builder - .WithOrigins( - configuration["App:CorsOrigins"] - .Split(",", StringSplitOptions.RemoveEmptyEntries) - .Select(o => o.RemovePostFix("/")) - .ToArray() - ) - .WithAbpExposedHeaders() - .WithAbpWrapExposedHeaders() - .SetIsOriginAllowedToAllowWildcardSubdomains() - .AllowAnyHeader() - .AllowAnyMethod() - .AllowCredentials(); - }); - }); - } - - private void ConfigureWeChat() - { - Configure(options => - { - // 回复文本消息 - options.MapMessage< - LINGYUN.Abp.WeChat.Official.Messages.Models.TextMessage, - LY.MicroService.Applications.Single.WeChat.Official.Messages.TextMessageReplyContributor>(); - // 处理关注事件 - options.MapEvent< - LINGYUN.Abp.WeChat.Official.Messages.Models.UserSubscribeEvent, - LY.MicroService.Applications.Single.WeChat.Official.Messages.UserSubscribeEventContributor>(); - - options.MapMessage< - LINGYUN.Abp.WeChat.Work.Common.Messages.Models.TextMessage, - LY.MicroService.Applications.Single.WeChat.Work.Messages.TextMessageReplyContributor>(); - }); - } -} +using Elsa; +using Elsa.Options; +using LINGYUN.Abp.Aliyun.Localization; +using LINGYUN.Abp.BackgroundTasks; +using LINGYUN.Abp.DataProtectionManagement; +using LINGYUN.Abp.Demo.Books; +using LINGYUN.Abp.Demo.Localization; +using LINGYUN.Abp.ExceptionHandling; +using LINGYUN.Abp.ExceptionHandling.Emailing; +using LINGYUN.Abp.Exporter.MiniExcel; +using LINGYUN.Abp.Idempotent; +using LINGYUN.Abp.Identity.Session; +using LINGYUN.Abp.IdentityServer.IdentityResources; +using LINGYUN.Abp.Localization.CultureMap; +using LINGYUN.Abp.Notifications; +using LINGYUN.Abp.OpenIddict.AspNetCore.Session; +using LINGYUN.Abp.OpenIddict.LinkUser; +using LINGYUN.Abp.OpenIddict.Permissions; +using LINGYUN.Abp.OpenIddict.Portal; +using LINGYUN.Abp.OpenIddict.Sms; +using LINGYUN.Abp.OpenIddict.WeChat; +using LINGYUN.Abp.Saas; +using LINGYUN.Abp.Serilog.Enrichers.Application; +using LINGYUN.Abp.Serilog.Enrichers.UniqueId; +using LINGYUN.Abp.Tencent.Localization; +using LINGYUN.Abp.TextTemplating; +using LINGYUN.Abp.WebhooksManagement; +using LINGYUN.Abp.WeChat.Common.Messages.Handlers; +using LINGYUN.Abp.WeChat.Localization; +using LINGYUN.Abp.WeChat.Work; +using LINGYUN.Abp.Wrapper; +using LINGYUN.Platform.Localization; +using LY.MicroService.Applications.Single.Authentication; +using LY.MicroService.Applications.Single.IdentityResources; +using Medallion.Threading; +using Medallion.Threading.Redis; +using Microsoft.AspNetCore.Authentication.Cookies; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.Extensions.Caching.StackExchangeRedis; +using Microsoft.IdentityModel.Logging; +using Microsoft.OpenApi.Models; +using MiniExcelLibs.Attributes; +using OpenIddict.Server; +using OpenIddict.Server.AspNetCore; +using Quartz; +using StackExchange.Redis; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text.Encodings.Web; +using System.Text.Unicode; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.AntiForgery; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.Auditing; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.BlobStoring; +using Volo.Abp.BlobStoring.FileSystem; +using Volo.Abp.BlobStoring.Minio; +using Volo.Abp.Caching; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.FeatureManagement; +using Volo.Abp.Features; +using Volo.Abp.GlobalFeatures; +using Volo.Abp.Http.Client; +using Volo.Abp.Identity.Localization; +using Volo.Abp.IdentityServer; +using Volo.Abp.IdentityServer.Localization; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Localization; +using Volo.Abp.MultiTenancy; +using Volo.Abp.OpenIddict; +using Volo.Abp.OpenIddict.Localization; +using Volo.Abp.PermissionManagement; +using Volo.Abp.Quartz; +using Volo.Abp.Security.Claims; +using Volo.Abp.SettingManagement; +using Volo.Abp.SettingManagement.Localization; +using Volo.Abp.Threading; +using Volo.Abp.UI.Navigation.Urls; +using Volo.Abp.VirtualFileSystem; +using VoloAbpExceptionHandlingOptions = Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingOptions; + +namespace LY.MicroService.Applications.Single; + +public partial class MicroServiceApplicationsSingleModule +{ + protected const string DefaultCorsPolicyName = "Default"; + public static string ApplicationName { get; set; } = "MicroService-Applications-Single"; + private readonly static OneTimeRunner OneTimeRunner = new(); + + private void PreConfigureFeature() + { + OneTimeRunner.Run(() => + { + GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); + }); + } + + private void PreConfigureApp(IConfiguration configuration) + { + AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; + + PreConfigure(options => + { + // 以开放端口区别,应在0-31之间 + options.SnowflakeIdOptions.WorkerId = 1; + options.SnowflakeIdOptions.WorkerIdBits = 5; + options.SnowflakeIdOptions.DatacenterId = 1; + }); + + if (configuration.GetValue("App:ShowPii")) + { + IdentityModelEventSource.ShowPII = true; + } + } + + private void PreConfigureAuthServer(IConfiguration configuration) + { + PreConfigure(builder => + { + builder.AddValidation(options => + { + //options.AddAudiences("lingyun-abp-application"); + + options.UseLocalServer(); + + options.UseAspNetCore(); + + options.UseDataProtection(); + }); + }); + } + + private void PreConfigureIdentity() + { + PreConfigure(builder => + { + builder.AddDefaultTokenProviders(); + }); + } + + private void PreConfigureCertificate(IConfiguration configuration, IWebHostEnvironment environment) + { + var cerConfig = configuration.GetSection("Certificates"); + if (environment.IsProduction() && cerConfig.Exists()) + { + // 开发环境下存在证书配置 + // 且证书文件存在则使用自定义的证书文件来启动Ids服务器 + var cerPath = Path.Combine(environment.ContentRootPath, cerConfig["CerPath"]); + if (File.Exists(cerPath)) + { + var certificate = new X509Certificate2(cerPath, cerConfig["Password"]); + + if (configuration.GetValue("AuthServer:UseOpenIddict")) + { + PreConfigure(options => + { + //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html + options.AddDevelopmentEncryptionAndSigningCertificate = false; + }); + + PreConfigure(builder => + { + builder.AddSigningCertificate(certificate); + builder.AddEncryptionCertificate(certificate); + + builder.UseDataProtection(); + + // 禁用https + builder.UseAspNetCore() + .DisableTransportSecurityRequirement(); + }); + } + else + { + PreConfigure(options => + { + options.AddDeveloperSigningCredential = false; + }); + + PreConfigure(builder => + { + builder.AddSigningCredential(certificate); + }); + } + } + } + else + { + if (configuration.GetValue("AuthServer:UseOpenIddict")) + { + PreConfigure(options => + { + //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html + options.AddDevelopmentEncryptionAndSigningCertificate = false; + }); + + PreConfigure(builder => + { + //https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html + using (var algorithm = RSA.Create(keySizeInBits: 2048)) + { + var subject = new X500DistinguishedName("CN=Fabrikam Encryption Certificate"); + var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); + request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature, critical: true)); + var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2)); + builder.AddSigningCertificate(certificate); + } + + using (var algorithm = RSA.Create(keySizeInBits: 2048)) + { + var subject = new X500DistinguishedName("CN=Fabrikam Signing Certificate"); + var request = new CertificateRequest(subject, algorithm, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); + request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment, critical: true)); + var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddYears(2)); + builder.AddEncryptionCertificate(certificate); + } + + builder.UseDataProtection(); + + // 禁用https + builder.UseAspNetCore() + .DisableTransportSecurityRequirement(); + }); + } + } + } + + private void PreConfigureQuartz(IConfiguration configuration) + { + PreConfigure(options => + { + // 如果使用持久化存储, 则配置quartz持久层 + if (configuration.GetSection("Quartz:UsePersistentStore").Get()) + { + var settings = configuration.GetSection("Quartz:Properties").Get>(); + if (settings != null) + { + foreach (var setting in settings) + { + options.Properties[setting.Key] = setting.Value; + } + } + + options.Configurator += (config) => + { + config.UsePersistentStore(store => + { + store.UseProperties = false; + store.UseNewtonsoftJsonSerializer(); + }); + }; + } + }); + } + + private void PreConfigureElsa(IServiceCollection services, IConfiguration configuration) + { + var elsaSection = configuration.GetSection("Elsa"); + var startups = new[] + { + typeof(Elsa.Activities.Console.Startup), + typeof(Elsa.Activities.Http.Startup), + typeof(Elsa.Activities.UserTask.Startup), + typeof(Elsa.Activities.Temporal.Quartz.Startup), + typeof(Elsa.Activities.Email.Startup), + typeof(Elsa.Scripting.JavaScript.Startup), + typeof(Elsa.Activities.Webhooks.Startup), + }; + + PreConfigure(elsa => + { + elsa + .AddActivitiesFrom() + .AddWorkflowsFrom() + .AddFeatures(startups, configuration) + .ConfigureWorkflowChannels(options => elsaSection.GetSection("WorkflowChannels").Bind(options)); + + elsa.DistributedLockingOptionsBuilder + .UseProviderFactory(sp => name => + { + var provider = sp.GetRequiredService(); + + return provider.CreateLock(name); + }); + }); + + services.AddNotificationHandlersFrom(); + + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(Elsa.Webhooks.Api.Endpoints.List).Assembly); + }); + } + + private void ConfigureAuthServer(IConfiguration configuration) + { + Configure(builder => + { + builder.DisableTransportSecurityRequirement(); + }); + + Configure(options => + { + options.DisableTransportSecurityRequirement = true; + }); + + Configure(options => + { + var lifetime = configuration.GetSection("OpenIddict:Lifetime"); + options.AuthorizationCodeLifetime = lifetime.GetValue("AuthorizationCode", options.AuthorizationCodeLifetime); + options.AccessTokenLifetime = lifetime.GetValue("AccessToken", options.AccessTokenLifetime); + options.DeviceCodeLifetime = lifetime.GetValue("DeviceCode", options.DeviceCodeLifetime); + options.IdentityTokenLifetime = lifetime.GetValue("IdentityToken", options.IdentityTokenLifetime); + options.RefreshTokenLifetime = lifetime.GetValue("RefreshToken", options.RefreshTokenLifetime); + options.RefreshTokenReuseLeeway = lifetime.GetValue("RefreshTokenReuseLeeway", options.RefreshTokenReuseLeeway); + options.UserCodeLifetime = lifetime.GetValue("UserCode", options.UserCodeLifetime); + }); + Configure(options => + { + options.PersistentSessionGrantTypes.Add(SmsTokenExtensionGrantConsts.GrantType); + options.PersistentSessionGrantTypes.Add(PortalTokenExtensionGrantConsts.GrantType); + options.PersistentSessionGrantTypes.Add(LinkUserTokenExtensionGrantConsts.GrantType); + options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.OfficialGrantType); + options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.MiniProgramGrantType); + options.PersistentSessionGrantTypes.Add(AbpWeChatWorkGlobalConsts.GrantType); + }); + } + + private void ConfigureEndpoints(IServiceCollection services) + { + // 不需要 + //Configure(options => + //{ + // options.EndpointConfigureActions.Add( + // (context) => + // { + // context.Endpoints.MapFallbackToPage("/_Host"); + // }); + //}); + var preActions = services.GetPreConfigureActions(); + + services.AddAbpApiVersioning(options => + { + options.ReportApiVersions = true; + options.AssumeDefaultVersionWhenUnspecified = true; + + //options.ApiVersionReader = new HeaderApiVersionReader("api-version"); //Supports header too + //options.ApiVersionReader = new MediaTypeApiVersionReader(); //Supports accept header too + }, mvcOptions => + { + mvcOptions.ConfigureAbp(preActions.Configure()); + }); + + //services.AddApiVersioning(config => + //{ + // // Specify the default API Version as 1.0 + // config.DefaultApiVersion = new ApiVersion(1, 0); + // // Advertise the API versions supported for the particular endpoint (through 'api-supported-versions' response header which lists all available API versions for that endpoint) + // config.ReportApiVersions = true; + //}); + + //services.AddVersionedApiExplorer(options => + //{ + // // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service + // // note: the specified format code will format the version as "'v'major[.minor][-status]" + // options.GroupNameFormat = "'v'VVV"; + + // // note: this option is only necessary when versioning by url segment. the SubstitutionFormat + // // can also be used to control the format of the API version in route templates + // options.SubstituteApiVersionInUrl = true; + //}); + } + + private void ConfigureKestrelServer() + { + Configure(options => + { + options.Limits.MaxRequestBodySize = null; + options.Limits.MaxRequestBufferSize = null; + }); + } + + private void ConfigureBlobStoring(IConfiguration configuration) + { + Configure(options => + { + options.Containers.ConfigureAll((containerName, containerConfiguration) => + { + containerConfiguration.UseFileSystem(fileSystem => + { + fileSystem.BasePath = Path.Combine(Directory.GetCurrentDirectory(), "blobs"); + }); + + //containerConfiguration.UseMinio(minio => + //{ + // configuration.GetSection("Minio").Bind(minio); + //}); + }); + }); + } + + private void ConfigureBackgroundTasks() + { + Configure(options => + { + options.NodeName = ApplicationName; + options.JobCleanEnabled = true; + options.JobFetchEnabled = true; + options.JobCheckEnabled = true; + }); + } + + private void ConfigureTextTemplating(IConfiguration configuration) + { + if (configuration.GetValue("TextTemplating:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicTemplateDefinitionStoreEnabled = true; + }); + } + } + + private void ConfigureFeatureManagement(IConfiguration configuration) + { + if (configuration.GetValue("FeatureManagement:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicFeatureStoreEnabled = true; + }); + } + Configure(options => + { + options.ProviderPolicies[EditionFeatureValueProvider.ProviderName] = AbpSaasPermissions.Editions.ManageFeatures; + options.ProviderPolicies[TenantFeatureValueProvider.ProviderName] = AbpSaasPermissions.Tenants.ManageFeatures; + }); + } + + private void ConfigureSettingManagement(IConfiguration configuration) + { + if (configuration.GetValue("SettingManagement:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicSettingStoreEnabled = true; + }); + } + } + + private void ConfigureWebhooksManagement(IConfiguration configuration) + { + if (configuration.GetValue("WebhooksManagement:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicWebhookStoreEnabled = true; + }); + } + } + /// + /// 配置数据导出 + /// + private void ConfigureExporter() + { + Configure(options => + { + options.MapExportSetting(typeof(BookDto), config => + { + config.DynamicColumns = new[] + { + // 忽略某些字段 + new DynamicExcelColumn(nameof(BookDto.AuthorId)){ Ignore = true }, + new DynamicExcelColumn(nameof(BookDto.LastModificationTime)){ Ignore = true }, + new DynamicExcelColumn(nameof(BookDto.LastModifierId)){ Ignore = true }, + new DynamicExcelColumn(nameof(BookDto.CreationTime)){ Ignore = true }, + new DynamicExcelColumn(nameof(BookDto.CreatorId)){ Ignore = true }, + new DynamicExcelColumn(nameof(BookDto.Id)){ Ignore = true }, + }; + }); + }); + } + /// + /// 配置数据权限 + /// + private void ConfigureEntityDataProtected() + { + Configure(options => + { + options.AddEntities(typeof(DemoResource), + new[] + { + typeof(Book), + }); + }); + } + + private void ConfigurePermissionManagement(IConfiguration configuration) + { + if (configuration.GetValue("PermissionManagement:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicPermissionStoreEnabled = true; + }); + } + Configure(options => + { + // Rename IdentityServer.Client.ManagePermissions + // See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs + options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpOpenIddictPermissions.Applications.ManagePermissions; + + //if (configuration.GetValue("AuthServer:UseOpenIddict")) + //{ + // options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpOpenIddictPermissions.Applications.ManagePermissions; + //} + //else + //{ + // options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = AbpIdentityServerPermissions.Clients.ManagePermissions; + //} + }); + } + + private void ConfigureNotificationManagement(IConfiguration configuration) + { + if (configuration.GetValue("NotificationsManagement:IsDynamicStoreEnabled")) + { + Configure(options => + { + options.IsDynamicNotificationsStoreEnabled = true; + }); + } + } + + private void ConfigureDistributedLock(IServiceCollection services, IConfiguration configuration) + { + var distributedLockEnabled = configuration["DistributedLock:IsEnabled"]; + if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) + { + var redis = ConnectionMultiplexer.Connect(configuration["DistributedLock:Redis:Configuration"]); + services.AddSingleton(_ => new RedisDistributedSynchronizationProvider(redis.GetDatabase())); + } + } + + private void ConfigureVirtualFileSystem() + { + Configure(options => + { + options.FileSets.AddEmbedded("LY.MicroService.Applications.Single"); + }); + } + + private void ConfigureIdempotent() + { + Configure(options => + { + options.IsEnabled = true; + options.DefaultTimeout = 0; + }); + } + + private void ConfigureDbContext() + { + Configure(options => + { + +#if POSTGRESQL + options.UseNpgsql(); +#else + options.UseMySQL(); +#endif + }); + } + + private void ConfigureDataSeeder() + { + Configure(options => + { + options.Resources.Add(new CustomIdentityResources.AvatarUrl()); + }); + } + + private void ConfigureExceptionHandling() + { + // 自定义需要处理的异常 + Configure(options => + { + // 加入需要处理的异常类型 + options.Handlers.Add(); + options.Handlers.Add(); + options.Handlers.Add(); + options.Handlers.Add(); + options.Handlers.Add(); + options.Handlers.Add(); + }); + // 自定义需要发送邮件通知的异常类型 + Configure(options => + { + // 是否发送堆栈信息 + options.SendStackTrace = true; + // 未指定异常接收者的默认接收邮件 + // 指定自己的邮件地址 + }); + + Configure(options => + { + options.SendStackTraceToClients = false; + options.SendExceptionsDetailsToClients = false; + }); + } + + private void ConfigureJsonSerializer(IConfiguration configuration) + { + // 统一时间日期格式 + Configure(options => + { + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } + }); + // 中文序列化的编码问题 + Configure(options => + { + options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + }); + } + + private void ConfigureCaching(IConfiguration configuration) + { + Configure(options => + { + configuration.GetSection("DistributedCache").Bind(options); + }); + + Configure(options => + { + var redisConfig = ConfigurationOptions.Parse(options.Configuration); + options.ConfigurationOptions = redisConfig; + options.InstanceName = configuration["Redis:InstanceName"]; + }); + } + + private void ConfigureMultiTenancy(IConfiguration configuration) + { + // 多租户 + Configure(options => + { + options.IsEnabled = true; + }); + + var tenantResolveCfg = configuration.GetSection("App:Domains"); + if (tenantResolveCfg.Exists()) + { + Configure(options => + { + var domains = tenantResolveCfg.Get(); + foreach (var domain in domains) + { + options.AddDomainTenantResolver(domain); + } + }); + } + } + + private void ConfigureAuditing(IConfiguration configuration) + { + Configure(options => + { + options.ApplicationName = ApplicationName; + // 是否启用实体变更记录 + var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; + if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || + (bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) + { + options.EntityHistorySelectors.AddAllEntities(); + } + }); + } + + private void ConfigureSwagger(IServiceCollection services) + { + // Swagger + services.AddSwaggerGen( + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "App API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", + Name = "Authorization", + In = ParameterLocation.Header, + Scheme = "bearer", + Type = SecuritySchemeType.Http, + BearerFormat = "JWT" + }); + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } + }, + new string[] { } + } + }); + options.OperationFilter(); + }); + } + + private void ConfigureIdentity(IConfiguration configuration) + { + // 增加配置文件定义,在新建租户时需要 + Configure(options => + { + var identityConfiguration = configuration.GetSection("Identity"); + if (identityConfiguration.Exists()) + { + identityConfiguration.Bind(options); + } + }); + Configure(options => + { + options.IsDynamicClaimsEnabled = true; + }); + Configure(options => + { + options.IsCleanupEnabled = true; + }); + } + + private void ConfigureMvcUiTheme() + { + Configure(options => + { + //options.StyleBundles.Configure( + // LeptonXLiteThemeBundles.Styles.Global, + // bundle => + // { + // bundle.AddFiles("/global-styles.css"); + // } + //); + }); + } + + private void ConfigureLocalization() + { + Configure(options => + { + options.Languages.Add(new LanguageInfo("en", "en", "English")); + options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); + + options + .AddLanguagesMapOrUpdate( + "vue-admin-element-ui", + new NameValue("zh-Hans", "zh"), + new NameValue("en", "en")); + + // vben admin 语言映射 + options + .AddLanguagesMapOrUpdate( + "vben-admin-ui", + new NameValue("zh_CN", "zh-Hans")); + + options.Resources.Get() + .AddBaseTypes( + typeof(IdentityResource), + typeof(AliyunResource), + typeof(TencentCloudResource), + typeof(WeChatResource), + typeof(PlatformResource), + typeof(AbpOpenIddictResource), + typeof(AbpIdentityServerResource)); + + options.UseAllPersistence(); + }); + + Configure(options => + { + var zhHansCultureMapInfo = new CultureMapInfo + { + TargetCulture = "zh-Hans", + SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } + }; + + options.CulturesMaps.Add(zhHansCultureMapInfo); + options.UiCulturesMaps.Add(zhHansCultureMapInfo); + }); + } + + private void ConfigureWrapper() + { + Configure(options => + { + options.IsEnabled = true; + // options.IsWrapUnauthorizedEnabled = true; + options.IgnoreNamespaces.Add("Elsa"); + }); + } + + private void PreConfigureWrapper() + { + //PreConfigure(options => + //{ + // options.ProxyRequestActions.Add( + // (appid, httprequestmessage) => + // { + // httprequestmessage.Headers.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); + // }); + //}); + + PreConfigure(options => + { + options.ProxyClientActions.Add( + (_, _, client) => + { + client.DefaultRequestHeaders.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); + }); + }); + } + + private void ConfigureAuditing() + { + Configure(options => + { + // options.IsEnabledForGetRequests = true; + options.ApplicationName = ApplicationName; + }); + } + + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => + { + var applicationConfiguration = configuration.GetSection("App:Urls:Applications"); + foreach (var appConfig in applicationConfiguration.GetChildren()) + { + options.Applications[appConfig.Key].RootUrl = appConfig["RootUrl"]; + foreach (var urlsConfig in appConfig.GetSection("Urls").GetChildren()) + { + options.Applications[appConfig.Key].Urls[urlsConfig.Key] = urlsConfig.Value; + } + } + }); + } + + private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) + { + Configure(options => + { + options.AutoValidate = false; + }); + + services.Replace(ServiceLifetime.Scoped); + + services.AddAuthentication() + .AddAbpJwtBearer(options => + { + configuration.GetSection("AuthServer").Bind(options); + + options.Events ??= new JwtBearerEvents(); + options.Events.OnMessageReceived = context => + { + var accessToken = context.Request.Query["access_token"]; + var path = context.HttpContext.Request.Path; + if (!string.IsNullOrEmpty(accessToken) && + (path.StartsWithSegments("/api/files"))) + { + context.Token = accessToken; + } + return Task.CompletedTask; + }; + }); + + if (!isDevelopment) + { + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + services + .AddDataProtection() + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); + } + + services.AddSameSiteCookiePolicy(); + } + + private void ConfigureCors(IServiceCollection services, IConfiguration configuration) + { + services.AddCors(options => + { + options.AddPolicy(DefaultCorsPolicyName, builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .WithAbpWrapExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + } + + private void ConfigureWeChat() + { + Configure(options => + { + // 回复文本消息 + options.MapMessage< + LINGYUN.Abp.WeChat.Official.Messages.Models.TextMessage, + LY.MicroService.Applications.Single.WeChat.Official.Messages.TextMessageReplyContributor>(); + // 处理关注事件 + options.MapEvent< + LINGYUN.Abp.WeChat.Official.Messages.Models.UserSubscribeEvent, + LY.MicroService.Applications.Single.WeChat.Official.Messages.UserSubscribeEventContributor>(); + + options.MapMessage< + LINGYUN.Abp.WeChat.Work.Common.Messages.Models.TextMessage, + LY.MicroService.Applications.Single.WeChat.Work.Messages.TextMessageReplyContributor>(); + }); + } +} diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs index fde8e6676..38a7cf91d 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs @@ -1,394 +1,407 @@ -using LINGYUN.Abp.Account; -using LINGYUN.Abp.Account.Templates; -using LINGYUN.Abp.Aliyun.SettingManagement; -using LINGYUN.Abp.AspNetCore.HttpOverrides; -using LINGYUN.Abp.AspNetCore.Mvc.Idempotent.Wrapper; -using LINGYUN.Abp.AspNetCore.Mvc.Localization; -using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; -using LINGYUN.Abp.Auditing; -using LINGYUN.Abp.AuditLogging.EntityFrameworkCore; -using LINGYUN.Abp.Authentication.QQ; -using LINGYUN.Abp.Authentication.WeChat; -using LINGYUN.Abp.Authorization.OrganizationUnits; -using LINGYUN.Abp.BackgroundTasks; -using LINGYUN.Abp.BackgroundTasks.Activities; -using LINGYUN.Abp.BackgroundTasks.DistributedLocking; -using LINGYUN.Abp.BackgroundTasks.EventBus; -using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; -using LINGYUN.Abp.BackgroundTasks.Jobs; -using LINGYUN.Abp.BackgroundTasks.Notifications; -using LINGYUN.Abp.BackgroundTasks.Quartz; -using LINGYUN.Abp.CachingManagement; -using LINGYUN.Abp.CachingManagement.StackExchangeRedis; -using LINGYUN.Abp.Dapr.Client; -using LINGYUN.Abp.Data.DbMigrator; -using LINGYUN.Abp.DataProtectionManagement; -using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore; -using LINGYUN.Abp.Demo; -using LINGYUN.Abp.Demo.EntityFrameworkCore; -using LINGYUN.Abp.Elsa; -using LINGYUN.Abp.Elsa.Activities; -using LINGYUN.Abp.Elsa.EntityFrameworkCore; -using LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql; -using LINGYUN.Abp.ExceptionHandling; -using LINGYUN.Abp.ExceptionHandling.Emailing; -using LINGYUN.Abp.Exporter.MiniExcel; -using LINGYUN.Abp.FeatureManagement; -using LINGYUN.Abp.FeatureManagement.HttpApi; -using LINGYUN.Abp.Features.LimitValidation; -using LINGYUN.Abp.Features.LimitValidation.Redis.Client; -using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity; -using LINGYUN.Abp.Identity.AspNetCore.Session; -using LINGYUN.Abp.Identity.EntityFrameworkCore; -using LINGYUN.Abp.Identity.Notifications; -using LINGYUN.Abp.Identity.OrganizaztionUnits; -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.Identity.WeChat; -using LINGYUN.Abp.IdGenerator; -using LINGYUN.Abp.IM.SignalR; -using LINGYUN.Abp.Localization.CultureMap; -using LINGYUN.Abp.Localization.Persistence; -using LINGYUN.Abp.LocalizationManagement; -using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; -using LINGYUN.Abp.MessageService; -using LINGYUN.Abp.MessageService.EntityFrameworkCore; -using LINGYUN.Abp.MultiTenancy.Editions; -using LINGYUN.Abp.Notifications; -using LINGYUN.Abp.Notifications.Common; -using LINGYUN.Abp.Notifications.Emailing; -using LINGYUN.Abp.Notifications.EntityFrameworkCore; -using LINGYUN.Abp.Notifications.SignalR; -using LINGYUN.Abp.Notifications.WeChat.MiniProgram; -using LINGYUN.Abp.OpenApi.Authorization; -using LINGYUN.Abp.OpenIddict; -using LINGYUN.Abp.OpenIddict.AspNetCore; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; -using LINGYUN.Abp.OpenIddict.Portal; -using LINGYUN.Abp.OpenIddict.Sms; -using LINGYUN.Abp.OpenIddict.WeChat; -using LINGYUN.Abp.OpenIddict.WeChat.Work; -using LINGYUN.Abp.OssManagement; -using LINGYUN.Abp.OssManagement.FileSystem; -using LINGYUN.Abp.OssManagement.Imaging; -using LINGYUN.Abp.OssManagement.Minio; -using LINGYUN.Abp.OssManagement.SettingManagement; -using LINGYUN.Abp.PermissionManagement; -using LINGYUN.Abp.PermissionManagement.HttpApi; -using LINGYUN.Abp.PermissionManagement.OrganizationUnits; -using LINGYUN.Abp.Saas; -using LINGYUN.Abp.Saas.EntityFrameworkCore; -using LINGYUN.Abp.Serilog.Enrichers.Application; -using LINGYUN.Abp.Serilog.Enrichers.UniqueId; -using LINGYUN.Abp.SettingManagement; -using LINGYUN.Abp.Sms.Aliyun; -using LINGYUN.Abp.TaskManagement; -using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; -using LINGYUN.Abp.Tencent.QQ; -using LINGYUN.Abp.Tencent.SettingManagement; -using LINGYUN.Abp.TextTemplating; -using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; -using LINGYUN.Abp.UI.Navigation; -using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; -using LINGYUN.Abp.Webhooks; -using LINGYUN.Abp.Webhooks.EventBus; -using LINGYUN.Abp.Webhooks.Identity; -using LINGYUN.Abp.Webhooks.Saas; -using LINGYUN.Abp.WebhooksManagement; -using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; -using LINGYUN.Abp.WeChat.MiniProgram; -using LINGYUN.Abp.WeChat.Official; -using LINGYUN.Abp.WeChat.Official.Handlers; -using LINGYUN.Abp.WeChat.SettingManagement; -using LINGYUN.Abp.WeChat.Work; -using LINGYUN.Abp.WeChat.Work.Handlers; -using LINGYUN.Platform; -using LINGYUN.Platform.EntityFrameworkCore; -using LINGYUN.Platform.HttpApi; -using LINGYUN.Platform.Settings.VueVbenAdmin; -using LINGYUN.Platform.Theme.VueVbenAdmin; -using LY.MicroService.Applications.Single.EntityFrameworkCore; -using Volo.Abp; -using Volo.Abp.Account.Web; -using Volo.Abp.AspNetCore.Authentication.JwtBearer; -using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; -using Volo.Abp.AspNetCore.Serilog; -using Volo.Abp.Autofac; -using Volo.Abp.Caching.StackExchangeRedis; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore.MySQL; -using Volo.Abp.EventBus; -using Volo.Abp.FeatureManagement.EntityFrameworkCore; -using Volo.Abp.Imaging; -using Volo.Abp.Modularity; -using Volo.Abp.OpenIddict.EntityFrameworkCore; -using Volo.Abp.PermissionManagement.EntityFrameworkCore; -using Volo.Abp.PermissionManagement.Identity; -using Volo.Abp.PermissionManagement.OpenIddict; -using Volo.Abp.SettingManagement; -using Volo.Abp.SettingManagement.EntityFrameworkCore; -using Volo.Abp.Threading; - -namespace LY.MicroService.Applications.Single; - -[DependsOn( - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpAccountWebOpenIddictModule), - typeof(AbpAuditingApplicationModule), - typeof(AbpAuditingHttpApiModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpCachingManagementStackExchangeRedisModule), - typeof(AbpCachingManagementApplicationModule), - typeof(AbpCachingManagementHttpApiModule), - typeof(AbpIdentityAspNetCoreSessionModule), - typeof(AbpIdentitySessionAspNetCoreModule), - typeof(AbpIdentityNotificationsModule), - typeof(AbpIdentityDomainModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpLocalizationManagementDomainModule), - typeof(AbpLocalizationManagementApplicationModule), - typeof(AbpLocalizationManagementHttpApiModule), - typeof(AbpLocalizationManagementEntityFrameworkCoreModule), - typeof(AbpSerilogEnrichersApplicationModule), - typeof(AbpSerilogEnrichersUniqueIdModule), - typeof(AbpMessageServiceDomainModule), - typeof(AbpMessageServiceApplicationModule), - typeof(AbpMessageServiceHttpApiModule), - typeof(AbpMessageServiceEntityFrameworkCoreModule), - typeof(AbpNotificationsDomainModule), - typeof(AbpNotificationsApplicationModule), - typeof(AbpNotificationsHttpApiModule), - typeof(AbpNotificationsEntityFrameworkCoreModule), - - //typeof(AbpIdentityServerSessionModule), - //typeof(AbpIdentityServerApplicationModule), - //typeof(AbpIdentityServerHttpApiModule), - //typeof(AbpIdentityServerEntityFrameworkCoreModule), - - typeof(AbpOpenIddictAspNetCoreModule), - typeof(AbpOpenIddictAspNetCoreSessionModule), - typeof(AbpOpenIddictApplicationModule), - typeof(AbpOpenIddictHttpApiModule), - typeof(AbpOpenIddictEntityFrameworkCoreModule), - typeof(AbpOpenIddictSmsModule), - typeof(AbpOpenIddictPortalModule), - typeof(AbpOpenIddictWeChatModule), - typeof(AbpOpenIddictWeChatWorkModule), - - //typeof(AbpOssManagementMinioModule), // 取消注释以使用Minio - typeof(AbpOssManagementFileSystemModule), - typeof(AbpOssManagementImagingModule), - typeof(AbpOssManagementDomainModule), - typeof(AbpOssManagementApplicationModule), - typeof(AbpOssManagementHttpApiModule), - typeof(AbpOssManagementSettingManagementModule), - typeof(AbpImagingImageSharpModule), - - typeof(PlatformDomainModule), - typeof(PlatformApplicationModule), - typeof(PlatformHttpApiModule), - typeof(PlatformEntityFrameworkCoreModule), - typeof(PlatformSettingsVueVbenAdminModule), - typeof(PlatformThemeVueVbenAdminModule), - typeof(AbpUINavigationVueVbenAdminModule), - - typeof(AbpSaasDomainModule), - typeof(AbpSaasApplicationModule), - typeof(AbpSaasHttpApiModule), - typeof(AbpSaasEntityFrameworkCoreModule), - - typeof(TaskManagementDomainModule), - typeof(TaskManagementApplicationModule), - typeof(TaskManagementHttpApiModule), - typeof(TaskManagementEntityFrameworkCoreModule), - - typeof(AbpTextTemplatingDomainModule), - typeof(AbpTextTemplatingApplicationModule), - typeof(AbpTextTemplatingHttpApiModule), - typeof(AbpTextTemplatingEntityFrameworkCoreModule), - - typeof(AbpWebhooksModule), - typeof(AbpWebhooksEventBusModule), - typeof(AbpWebhooksIdentityModule), - typeof(AbpWebhooksSaasModule), - typeof(WebhooksManagementDomainModule), - typeof(WebhooksManagementApplicationModule), - typeof(WebhooksManagementHttpApiModule), - typeof(WebhooksManagementEntityFrameworkCoreModule), - - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpFeatureManagementHttpApiModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule), - - typeof(AbpSettingManagementDomainModule), - typeof(AbpSettingManagementApplicationModule), - typeof(AbpSettingManagementHttpApiModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpPermissionManagementDomainOpenIddictModule), - // typeof(AbpPermissionManagementDomainIdentityServerModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理 - - typeof(SingleMigrationsEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreMySQLModule), - - typeof(AbpAliyunSmsModule), - typeof(AbpAliyunSettingManagementModule), - - typeof(AbpAuthenticationQQModule), - typeof(AbpAuthenticationWeChatModule), - typeof(AbpAuthorizationOrganizationUnitsModule), - typeof(AbpIdentityOrganizaztionUnitsModule), - - typeof(AbpBackgroundTasksModule), - typeof(AbpBackgroundTasksActivitiesModule), - typeof(AbpBackgroundTasksDistributedLockingModule), - typeof(AbpBackgroundTasksEventBusModule), - typeof(AbpBackgroundTasksExceptionHandlingModule), - typeof(AbpBackgroundTasksJobsModule), - typeof(AbpBackgroundTasksNotificationsModule), - typeof(AbpBackgroundTasksQuartzModule), - - typeof(AbpDataProtectionManagementApplicationModule), - typeof(AbpDataProtectionManagementHttpApiModule), - typeof(AbpDataProtectionManagementEntityFrameworkCoreModule), - - typeof(AbpDemoApplicationModule), - typeof(AbpDemoHttpApiModule), - typeof(AbpDemoEntityFrameworkCoreModule), - - typeof(AbpDaprClientModule), - typeof(AbpExceptionHandlingModule), - typeof(AbpEmailingExceptionHandlingModule), - typeof(AbpFeaturesLimitValidationModule), - typeof(AbpFeaturesValidationRedisClientModule), - typeof(AbpAspNetCoreMvcLocalizationModule), - - typeof(AbpLocalizationCultureMapModule), - typeof(AbpLocalizationPersistenceModule), - - typeof(AbpOpenApiAuthorizationModule), - - typeof(AbpIMSignalRModule), - - typeof(AbpNotificationsModule), - typeof(AbpNotificationsCommonModule), - typeof(AbpNotificationsSignalRModule), - typeof(AbpNotificationsEmailingModule), - typeof(AbpMultiTenancyEditionsModule), - - typeof(AbpTencentQQModule), - typeof(AbpTencentCloudSettingManagementModule), - - typeof(AbpIdentityWeChatModule), - typeof(AbpNotificationsWeChatMiniProgramModule), - typeof(AbpWeChatMiniProgramModule), - typeof(AbpWeChatOfficialModule), - typeof(AbpWeChatOfficialApplicationModule), - typeof(AbpWeChatOfficialHttpApiModule), - typeof(AbpWeChatWorkModule), - typeof(AbpWeChatWorkApplicationModule), - typeof(AbpWeChatWorkHttpApiModule), - typeof(AbpWeChatOfficialHandlersModule), - typeof(AbpWeChatWorkHandlersModule), - typeof(AbpWeChatSettingManagementModule), - - typeof(AbpDataDbMigratorModule), - typeof(AbpIdGeneratorModule), - typeof(AbpUINavigationModule), - typeof(AbpAccountTemplatesModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpCachingStackExchangeRedisModule), - - typeof(AbpElsaModule), - typeof(AbpElsaServerModule), - typeof(AbpElsaActivitiesModule), - typeof(AbpElsaEntityFrameworkCoreModule), - typeof(AbpElsaEntityFrameworkCoreMySqlModule), - - typeof(AbpExporterMiniExcelModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpHttpClientWrapperModule), - typeof(AbpAspNetCoreMvcWrapperModule), - typeof(AbpAspNetCoreMvcIdempotentWrapperModule), - typeof(AbpAspNetCoreHttpOverridesModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpEventBusModule), - typeof(AbpAutofacModule) - )] -public partial class MicroServiceApplicationsSingleModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - var configuration = context.Services.GetConfiguration(); - var hostingEnvironment = context.Services.GetHostingEnvironment(); - - PreConfigureWrapper(); - PreConfigureFeature(); - PreConfigureIdentity(); - PreConfigureApp(configuration); - PreConfigureQuartz(configuration); - PreConfigureAuthServer(configuration); - PreConfigureElsa(context.Services, configuration); - PreConfigureCertificate(configuration, hostingEnvironment); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); - - ConfigureWeChat(); - ConfigureWrapper(); - ConfigureExporter(); - ConfigureAuditing(); - ConfigureDbContext(); - ConfigureIdempotent(); - ConfigureMvcUiTheme(); - ConfigureDataSeeder(); - ConfigureLocalization(); - ConfigureKestrelServer(); - ConfigureBackgroundTasks(); - ConfigureExceptionHandling(); - ConfigureVirtualFileSystem(); - ConfigureEntityDataProtected(); - ConfigureUrls(configuration); - ConfigureCaching(configuration); - ConfigureAuditing(configuration); - ConfigureIdentity(configuration); - ConfigureAuthServer(configuration); - ConfigureSwagger(context.Services); - ConfigureEndpoints(context.Services); - ConfigureBlobStoring(configuration); - ConfigureMultiTenancy(configuration); - ConfigureJsonSerializer(configuration); - ConfigureTextTemplating(configuration); - ConfigureFeatureManagement(configuration); - ConfigureSettingManagement(configuration); - ConfigureWebhooksManagement(configuration); - ConfigurePermissionManagement(configuration); - ConfigureNotificationManagement(configuration); - ConfigureCors(context.Services, configuration); - ConfigureDistributedLock(context.Services, configuration); - ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); - } - - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - AsyncHelper.RunSync(async () => await OnApplicationInitializationAsync(context)); - } - - public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) - { - await context.ServiceProvider.GetRequiredService().SeedAsync(); ; - } -} +using LINGYUN.Abp.Account; +using LINGYUN.Abp.Account.Templates; +using LINGYUN.Abp.Aliyun.SettingManagement; +using LINGYUN.Abp.AspNetCore.HttpOverrides; +using LINGYUN.Abp.AspNetCore.Mvc.Idempotent.Wrapper; +using LINGYUN.Abp.AspNetCore.Mvc.Localization; +using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.Auditing; +using LINGYUN.Abp.AuditLogging.EntityFrameworkCore; +using LINGYUN.Abp.Authentication.QQ; +using LINGYUN.Abp.Authentication.WeChat; +using LINGYUN.Abp.Authorization.OrganizationUnits; +using LINGYUN.Abp.BackgroundTasks; +using LINGYUN.Abp.BackgroundTasks.Activities; +using LINGYUN.Abp.BackgroundTasks.DistributedLocking; +using LINGYUN.Abp.BackgroundTasks.EventBus; +using LINGYUN.Abp.BackgroundTasks.ExceptionHandling; +using LINGYUN.Abp.BackgroundTasks.Jobs; +using LINGYUN.Abp.BackgroundTasks.Notifications; +using LINGYUN.Abp.BackgroundTasks.Quartz; +using LINGYUN.Abp.CachingManagement; +using LINGYUN.Abp.CachingManagement.StackExchangeRedis; +using LINGYUN.Abp.Dapr.Client; +using LINGYUN.Abp.Data.DbMigrator; +using LINGYUN.Abp.DataProtectionManagement; +using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore; +using LINGYUN.Abp.Demo; +using LINGYUN.Abp.Demo.EntityFrameworkCore; +using LINGYUN.Abp.Elsa; +using LINGYUN.Abp.Elsa.Activities; +using LINGYUN.Abp.Elsa.EntityFrameworkCore; +#if POSTGRESQL +using Volo.Abp.EntityFrameworkCore.PostgreSql; +using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql; +#else +using LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql; +#endif +using LINGYUN.Abp.ExceptionHandling; +using LINGYUN.Abp.ExceptionHandling.Emailing; +using LINGYUN.Abp.Exporter.MiniExcel; +using LINGYUN.Abp.FeatureManagement; +using LINGYUN.Abp.FeatureManagement.HttpApi; +using LINGYUN.Abp.Features.LimitValidation; +using LINGYUN.Abp.Features.LimitValidation.Redis.Client; +using LINGYUN.Abp.Http.Client.Wrapper; +using LINGYUN.Abp.Identity; +using LINGYUN.Abp.Identity.AspNetCore.Session; +using LINGYUN.Abp.Identity.EntityFrameworkCore; +using LINGYUN.Abp.Identity.Notifications; +using LINGYUN.Abp.Identity.OrganizaztionUnits; +using LINGYUN.Abp.Identity.Session.AspNetCore; +using LINGYUN.Abp.Identity.WeChat; +using LINGYUN.Abp.IdGenerator; +using LINGYUN.Abp.IM.SignalR; +using LINGYUN.Abp.Localization.CultureMap; +using LINGYUN.Abp.Localization.Persistence; +using LINGYUN.Abp.LocalizationManagement; +using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; +using LINGYUN.Abp.MessageService; +using LINGYUN.Abp.MessageService.EntityFrameworkCore; +using LINGYUN.Abp.MultiTenancy.Editions; +using LINGYUN.Abp.Notifications; +using LINGYUN.Abp.Notifications.Common; +using LINGYUN.Abp.Notifications.Emailing; +using LINGYUN.Abp.Notifications.EntityFrameworkCore; +using LINGYUN.Abp.Notifications.SignalR; +using LINGYUN.Abp.Notifications.WeChat.MiniProgram; +using LINGYUN.Abp.OpenApi.Authorization; +using LINGYUN.Abp.OpenIddict; +using LINGYUN.Abp.OpenIddict.AspNetCore; +using LINGYUN.Abp.OpenIddict.AspNetCore.Session; +using LINGYUN.Abp.OpenIddict.Portal; +using LINGYUN.Abp.OpenIddict.Sms; +using LINGYUN.Abp.OpenIddict.WeChat; +using LINGYUN.Abp.OpenIddict.WeChat.Work; +using LINGYUN.Abp.OssManagement; +using LINGYUN.Abp.OssManagement.FileSystem; +using LINGYUN.Abp.OssManagement.Imaging; +using LINGYUN.Abp.OssManagement.Minio; +using LINGYUN.Abp.OssManagement.SettingManagement; +using LINGYUN.Abp.PermissionManagement; +using LINGYUN.Abp.PermissionManagement.HttpApi; +using LINGYUN.Abp.PermissionManagement.OrganizationUnits; +using LINGYUN.Abp.Saas; +using LINGYUN.Abp.Saas.EntityFrameworkCore; +using LINGYUN.Abp.Serilog.Enrichers.Application; +using LINGYUN.Abp.Serilog.Enrichers.UniqueId; +using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.Sms.Aliyun; +using LINGYUN.Abp.TaskManagement; +using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; +using LINGYUN.Abp.Tencent.QQ; +using LINGYUN.Abp.Tencent.SettingManagement; +using LINGYUN.Abp.TextTemplating; +using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; +using LINGYUN.Abp.UI.Navigation; +using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; +using LINGYUN.Abp.Webhooks; +using LINGYUN.Abp.Webhooks.EventBus; +using LINGYUN.Abp.Webhooks.Identity; +using LINGYUN.Abp.Webhooks.Saas; +using LINGYUN.Abp.WebhooksManagement; +using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; +using LINGYUN.Abp.WeChat.MiniProgram; +using LINGYUN.Abp.WeChat.Official; +using LINGYUN.Abp.WeChat.Official.Handlers; +using LINGYUN.Abp.WeChat.SettingManagement; +using LINGYUN.Abp.WeChat.Work; +using LINGYUN.Abp.WeChat.Work.Handlers; +using LINGYUN.Platform; +using LINGYUN.Platform.EntityFrameworkCore; +using LINGYUN.Platform.HttpApi; +using LINGYUN.Platform.Settings.VueVbenAdmin; +using LINGYUN.Platform.Theme.VueVbenAdmin; +using LY.MicroService.Applications.Single.EntityFrameworkCore; +using Volo.Abp; +using Volo.Abp.Account.Web; +using Volo.Abp.AspNetCore.Authentication.JwtBearer; +using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Serilog; +using Volo.Abp.Autofac; +using Volo.Abp.Caching.StackExchangeRedis; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore.MySQL; +using Volo.Abp.EventBus; +using Volo.Abp.FeatureManagement.EntityFrameworkCore; +using Volo.Abp.Imaging; +using Volo.Abp.Modularity; +using Volo.Abp.OpenIddict.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.Identity; +using Volo.Abp.PermissionManagement.OpenIddict; +using Volo.Abp.SettingManagement; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.Threading; + +namespace LY.MicroService.Applications.Single; + +[DependsOn( + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpAccountWebOpenIddictModule), + typeof(AbpAuditingApplicationModule), + typeof(AbpAuditingHttpApiModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpCachingManagementStackExchangeRedisModule), + typeof(AbpCachingManagementApplicationModule), + typeof(AbpCachingManagementHttpApiModule), + typeof(AbpIdentityAspNetCoreSessionModule), + typeof(AbpIdentitySessionAspNetCoreModule), + typeof(AbpIdentityNotificationsModule), + typeof(AbpIdentityDomainModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpLocalizationManagementDomainModule), + typeof(AbpLocalizationManagementApplicationModule), + typeof(AbpLocalizationManagementHttpApiModule), + typeof(AbpLocalizationManagementEntityFrameworkCoreModule), + typeof(AbpSerilogEnrichersApplicationModule), + typeof(AbpSerilogEnrichersUniqueIdModule), + typeof(AbpMessageServiceDomainModule), + typeof(AbpMessageServiceApplicationModule), + typeof(AbpMessageServiceHttpApiModule), + typeof(AbpMessageServiceEntityFrameworkCoreModule), + typeof(AbpNotificationsDomainModule), + typeof(AbpNotificationsApplicationModule), + typeof(AbpNotificationsHttpApiModule), + typeof(AbpNotificationsEntityFrameworkCoreModule), + + //typeof(AbpIdentityServerSessionModule), + //typeof(AbpIdentityServerApplicationModule), + //typeof(AbpIdentityServerHttpApiModule), + //typeof(AbpIdentityServerEntityFrameworkCoreModule), + + typeof(AbpOpenIddictAspNetCoreModule), + typeof(AbpOpenIddictAspNetCoreSessionModule), + typeof(AbpOpenIddictApplicationModule), + typeof(AbpOpenIddictHttpApiModule), + typeof(AbpOpenIddictEntityFrameworkCoreModule), + typeof(AbpOpenIddictSmsModule), + typeof(AbpOpenIddictPortalModule), + typeof(AbpOpenIddictWeChatModule), + typeof(AbpOpenIddictWeChatWorkModule), + + //typeof(AbpOssManagementMinioModule), // 取消注释以使用Minio + typeof(AbpOssManagementFileSystemModule), + typeof(AbpOssManagementImagingModule), + typeof(AbpOssManagementDomainModule), + typeof(AbpOssManagementApplicationModule), + typeof(AbpOssManagementHttpApiModule), + typeof(AbpOssManagementSettingManagementModule), + typeof(AbpImagingImageSharpModule), + + typeof(PlatformDomainModule), + typeof(PlatformApplicationModule), + typeof(PlatformHttpApiModule), + typeof(PlatformEntityFrameworkCoreModule), + typeof(PlatformSettingsVueVbenAdminModule), + typeof(PlatformThemeVueVbenAdminModule), + typeof(AbpUINavigationVueVbenAdminModule), + + typeof(AbpSaasDomainModule), + typeof(AbpSaasApplicationModule), + typeof(AbpSaasHttpApiModule), + typeof(AbpSaasEntityFrameworkCoreModule), + + typeof(TaskManagementDomainModule), + typeof(TaskManagementApplicationModule), + typeof(TaskManagementHttpApiModule), + typeof(TaskManagementEntityFrameworkCoreModule), + + typeof(AbpTextTemplatingDomainModule), + typeof(AbpTextTemplatingApplicationModule), + typeof(AbpTextTemplatingHttpApiModule), + typeof(AbpTextTemplatingEntityFrameworkCoreModule), + + typeof(AbpWebhooksModule), + typeof(AbpWebhooksEventBusModule), + typeof(AbpWebhooksIdentityModule), + typeof(AbpWebhooksSaasModule), + typeof(WebhooksManagementDomainModule), + typeof(WebhooksManagementApplicationModule), + typeof(WebhooksManagementHttpApiModule), + typeof(WebhooksManagementEntityFrameworkCoreModule), + + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpFeatureManagementHttpApiModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule), + + typeof(AbpSettingManagementDomainModule), + typeof(AbpSettingManagementApplicationModule), + typeof(AbpSettingManagementHttpApiModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpPermissionManagementDomainOpenIddictModule), + // typeof(AbpPermissionManagementDomainIdentityServerModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理 + + typeof(SingleMigrationsEntityFrameworkCoreModule), +#if POSTGRESQL + typeof(AbpEntityFrameworkCorePostgreSqlModule), +#else + typeof(AbpEntityFrameworkCoreMySQLModule), +#endif + + typeof(AbpAliyunSmsModule), + typeof(AbpAliyunSettingManagementModule), + + typeof(AbpAuthenticationQQModule), + typeof(AbpAuthenticationWeChatModule), + typeof(AbpAuthorizationOrganizationUnitsModule), + typeof(AbpIdentityOrganizaztionUnitsModule), + + typeof(AbpBackgroundTasksModule), + typeof(AbpBackgroundTasksActivitiesModule), + typeof(AbpBackgroundTasksDistributedLockingModule), + typeof(AbpBackgroundTasksEventBusModule), + typeof(AbpBackgroundTasksExceptionHandlingModule), + typeof(AbpBackgroundTasksJobsModule), + typeof(AbpBackgroundTasksNotificationsModule), + typeof(AbpBackgroundTasksQuartzModule), + + typeof(AbpDataProtectionManagementApplicationModule), + typeof(AbpDataProtectionManagementHttpApiModule), + typeof(AbpDataProtectionManagementEntityFrameworkCoreModule), + + typeof(AbpDemoApplicationModule), + typeof(AbpDemoHttpApiModule), + typeof(AbpDemoEntityFrameworkCoreModule), + + typeof(AbpDaprClientModule), + typeof(AbpExceptionHandlingModule), + typeof(AbpEmailingExceptionHandlingModule), + typeof(AbpFeaturesLimitValidationModule), + typeof(AbpFeaturesValidationRedisClientModule), + typeof(AbpAspNetCoreMvcLocalizationModule), + + typeof(AbpLocalizationCultureMapModule), + typeof(AbpLocalizationPersistenceModule), + + typeof(AbpOpenApiAuthorizationModule), + + typeof(AbpIMSignalRModule), + + typeof(AbpNotificationsModule), + typeof(AbpNotificationsCommonModule), + typeof(AbpNotificationsSignalRModule), + typeof(AbpNotificationsEmailingModule), + typeof(AbpMultiTenancyEditionsModule), + + typeof(AbpTencentQQModule), + typeof(AbpTencentCloudSettingManagementModule), + + typeof(AbpIdentityWeChatModule), + typeof(AbpNotificationsWeChatMiniProgramModule), + typeof(AbpWeChatMiniProgramModule), + typeof(AbpWeChatOfficialModule), + typeof(AbpWeChatOfficialApplicationModule), + typeof(AbpWeChatOfficialHttpApiModule), + typeof(AbpWeChatWorkModule), + typeof(AbpWeChatWorkApplicationModule), + typeof(AbpWeChatWorkHttpApiModule), + typeof(AbpWeChatOfficialHandlersModule), + typeof(AbpWeChatWorkHandlersModule), + typeof(AbpWeChatSettingManagementModule), + + typeof(AbpDataDbMigratorModule), + typeof(AbpIdGeneratorModule), + typeof(AbpUINavigationModule), + typeof(AbpAccountTemplatesModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpCachingStackExchangeRedisModule), + + typeof(AbpElsaModule), + typeof(AbpElsaServerModule), + typeof(AbpElsaActivitiesModule), + typeof(AbpElsaEntityFrameworkCoreModule), +#if POSTGRESQL + typeof(AbpElsaEntityFrameworkCorePostgreSqlModule), +#else + typeof(AbpElsaEntityFrameworkCoreMySqlModule), +#endif + + typeof(AbpExporterMiniExcelModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpHttpClientWrapperModule), + typeof(AbpAspNetCoreMvcWrapperModule), + typeof(AbpAspNetCoreMvcIdempotentWrapperModule), + typeof(AbpAspNetCoreHttpOverridesModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpEventBusModule), + typeof(AbpAutofacModule) + )] +public partial class MicroServiceApplicationsSingleModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + + PreConfigureWrapper(); + PreConfigureFeature(); + PreConfigureIdentity(); + PreConfigureApp(configuration); + PreConfigureQuartz(configuration); + PreConfigureAuthServer(configuration); + PreConfigureElsa(context.Services, configuration); + PreConfigureCertificate(configuration, hostingEnvironment); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + ConfigureWeChat(); + ConfigureWrapper(); + ConfigureExporter(); + ConfigureAuditing(); + ConfigureDbContext(); + ConfigureIdempotent(); + ConfigureMvcUiTheme(); + ConfigureDataSeeder(); + ConfigureLocalization(); + ConfigureKestrelServer(); + ConfigureBackgroundTasks(); + ConfigureExceptionHandling(); + ConfigureVirtualFileSystem(); + ConfigureEntityDataProtected(); + ConfigureUrls(configuration); + ConfigureCaching(configuration); + ConfigureAuditing(configuration); + ConfigureIdentity(configuration); + ConfigureAuthServer(configuration); + ConfigureSwagger(context.Services); + ConfigureEndpoints(context.Services); + ConfigureBlobStoring(configuration); + ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); + ConfigureTextTemplating(configuration); + ConfigureFeatureManagement(configuration); + ConfigureSettingManagement(configuration); + ConfigureWebhooksManagement(configuration); + ConfigurePermissionManagement(configuration); + ConfigureNotificationManagement(configuration); + ConfigureCors(context.Services, configuration); + ConfigureDistributedLock(context.Services, configuration); + ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => await OnApplicationInitializationAsync(context)); + } + + public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + await context.ServiceProvider.GetRequiredService().SeedAsync(); ; + } +} diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.PostgreSql.json b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.PostgreSql.json new file mode 100644 index 000000000..62cbaeef1 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.PostgreSql.json @@ -0,0 +1,262 @@ +{ + "App": { + "ShowPii": true, + "SelfUrl": "http://127.0.0.1:30001/", + "CorsOrigins": "http://127.0.0.1:3100,http://127.0.0.1:30001", + "Urls": { + "Applications": { + "MVC": { + "RootUrl": "http://127.0.0.1:30001/", + "Urls": { + "Abp.Account.EmailConfirm": "Account/EmailConfirm", + "Abp.Account.EmailVerifyLogin": "Account/VerifyCode" + } + }, + "STS": { + "RootUrl": "http://127.0.0.1:30001/" + }, + "VueVbenAdmin": { + "RootUrl": "http://127.0.0.1:3100", + "Urls": { + "Abp.Account.EmailConfirm": "account/email-confirm" + } + } + } + } + }, + "Auditing": { + "AllEntitiesSelector": true + }, + "DistributedCache": { + "HideErrors": true, + "KeyPrefix": "LINGYUN.Abp.Application", + "GlobalCacheEntryOptions": { + "SlidingExpiration": "30:00:00", + "AbsoluteExpirationRelativeToNow": "60:00:00" + } + }, + "ConnectionStrings": { + "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpAuditLogging": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpOpenIddict": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpIdentity": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpIdentityServer": "Host=127.0.0.1;Database=IdentityServer-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpSaas": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpTenantManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpFeatureManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpSettingManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpPermissionManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpLocalizationManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AbpTextTemplating": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "AppPlatform": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "TaskManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Workflow": "Host=127.0.0.1;Database=Workflow-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Notifications": "Host=127.0.0.1;Database=Messages-V70;Username=postgres;Password=123456;SslMode=Prefer", + "MessageService": "Host=127.0.0.1;Database=Messages-V70;Username=postgres;Password=123456;SslMode=Prefer", + "Demo": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer" + }, + "DistributedLock": { + "IsEnabled": true, + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=14" + } + }, + "Elsa": { + "Features": { + "DefaultPersistence": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "PostgreSql": { + "Enabled": true + } + } + }, + "Console": true, + "Http": true, + "Email": true, + "TemporalQuartz": true, + "JavaScriptActivities": true, + "UserTask": true, + "Conductor": true, + "Telnyx": true, + "BlobStoring": true, + "Emailing": true, + "Notification": true, + "Sms": true, + "IM": true, + "PublishWebhook": true, + "Webhooks": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "PostgreSql": { + "Enabled": true + } + } + }, + "WorkflowSettings": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "PostgreSql": { + "Enabled": true + } + } + } + }, + "Server": { + "BaseUrl": "http://127.0.0.1:30000" + } + }, + "Quartz": { + "UsePersistentStore": true, + "Properties": { + "quartz.jobStore.dataSource": "tkm", + "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz", + "quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate, Quartz", + "quartz.dataSource.tkm.connectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer", + "quartz.dataSource.tkm.provider": "Npgsql", + "quartz.jobStore.clustered": "true", + "quartz.serializer.type": "json", + "quartz.dataSource.tkm.connectionStringName": "TaskManagement" + } + }, + "Redis": { + "IsEnabled": true, + "Configuration": "127.0.0.1,defaultDatabase=15", + "InstanceName": "LINGYUN.Abp.Application" + }, + "Features": { + "Validation": { + "Redis": { + "Configuration": "127.0.0.1,defaultDatabase=13", + "InstanceName": "LINGYUN.Abp.Application" + } + } + }, + "AuthServer": { + "UseOpenIddict": true, + "Authority": "http://127.0.0.1:30001/", + "Audience": "lingyun-abp-application", + "RequireHttpsMetadata": false, + "SwaggerClientId": "InternalServiceClient", + "SwaggerClientSecret": "1q2w3E*" + }, + "IdentityServer": { + "Clients": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + }, + "InternalService": { + "ClientId": "InternalServiceClient" + } + } + }, + "OpenIddict": { + "Applications": { + "VueAdmin": { + "ClientId": "vue-admin-client", + "RootUrl": "http://127.0.0.1:3100/" + }, + "InternalService": { + "ClientId": "InternalServiceClient" + } + }, + "Lifetime": { + "AuthorizationCode": "00:05:00", + "AccessToken": "14:00:00", + "DeviceCode": "00:10:00", + "IdentityToken": "00:20:00", + "RefreshToken": "14:00:00", + "RefreshTokenReuseLeeway": "00:00:30", + "UserCode": "00:10:00" + } + }, + "Identity": { + "Password": { + "RequiredLength": 6, + "RequiredUniqueChars": 0, + "RequireNonAlphanumeric": false, + "RequireLowercase": false, + "RequireUppercase": false, + "RequireDigit": false + }, + "Lockout": { + "AllowedForNewUsers": false, + "LockoutDuration": 5, + "MaxFailedAccessAttempts": 5 + }, + "SignIn": { + "RequireConfirmedEmail": false, + "RequireConfirmedPhoneNumber": false + } + }, + "FeatureManagement": { + "IsDynamicStoreEnabled": true + }, + "SettingManagement": { + "IsDynamicStoreEnabled": true + }, + "PermissionManagement": { + "IsDynamicStoreEnabled": true + }, + "TextTemplating": { + "IsDynamicStoreEnabled": true + }, + "WebhooksManagement": { + "IsDynamicStoreEnabled": true + }, + "Logging": { + "Serilog": { + "Elasticsearch": { + "IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" + } + } + }, + "AuditLogging": { + "Elasticsearch": { + "IndexPrefix": "abp.dev.auditing" + } + }, + "Elasticsearch": { + "NodeUris": "http://127.0.0.1:9200" + }, + "Minio": { + "WithSSL": false, + "BucketName": "blobs", + "EndPoint": "127.0.0.1:19000", + "AccessKey": "ZD43kNpimiJf9mCuomTP", + "SecretKey": "w8IqMgi4Tnz0DGzN8jZ7IJWq7OEdbUnAU0jlZxQK", + "CreateBucketIfNotExists": false + }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "System": "Warning", + "Microsoft": "Warning", + "DotNetCore": "Warning" + } + }, + "WriteTo": [ + { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Debug", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" + } + }, + { + "Name": "Elasticsearch", + "Args": { + "nodeUris": "http://127.0.0.1:9200", + "indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", + "autoRegisterTemplate": true, + "autoRegisterTemplateVersion": "ESv7" + } + } + ] + } +} diff --git a/common.props b/common.props index b94fc2553..cd370d567 100644 --- a/common.props +++ b/common.props @@ -1,38 +1,44 @@ - - - latest - 8.3.0 - colin - $(NoWarn);CS1591;CS0436;CS8618;NU1803 - https://github.com/colinin/abp-next-admin - $(SolutionDir)LocalNuget - 8.3.0 - MIT - git - https://github.com/colinin/abp-next-admin - true - - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)LocalNuget - - + + + latest + 8.3.0 + colin + $(NoWarn);CS1591;CS0436;CS8618;NU1803 + https://github.com/colinin/abp-next-admin + $(SolutionDir)LocalNuget + 8.3.0 + MIT + git + https://github.com/colinin/abp-next-admin + true + Debug;Release;PostgreSQL + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)LocalNuget + + + + POSTGRESQL + $(SolutionDir)LocalNuget + + \ No newline at end of file