263 changed files with 33466 additions and 111 deletions
File diff suppressed because it is too large
@ -0,0 +1,7 @@ |
|||
.aspire |
|||
wwwroot |
|||
node_modules |
|||
blobs |
|||
bin |
|||
obj |
|||
yarn.lock |
|||
@ -0,0 +1,52 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
public class AdminServiceDbMigratorHostedService : IHostedService |
|||
{ |
|||
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public AdminServiceDbMigratorHostedService( |
|||
IHostApplicationLifetime hostApplicationLifetime, |
|||
IConfiguration configuration) |
|||
{ |
|||
_hostApplicationLifetime = hostApplicationLifetime; |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using var application = await AbpApplicationFactory |
|||
.CreateAsync<AdminServiceDbMigratorModule>(options => |
|||
{ |
|||
options.Services.ReplaceConfiguration(_configuration); |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
options.AddDataMigrationEnvironment(); |
|||
}); |
|||
|
|||
await application.InitializeAsync(); |
|||
|
|||
await application |
|||
.ServiceProvider |
|||
.GetRequiredService<AdminServiceDbMigrationService>() |
|||
.CheckAndApplyDatabaseMigrationsAsync(); |
|||
|
|||
await application.ShutdownAsync(); |
|||
|
|||
_hostApplicationLifetime.StopApplication(); |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AdminServiceMigrationsEntityFrameworkCoreModule) |
|||
)] |
|||
public class AdminServiceDbMigratorModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<IsPackable>false</IsPackable> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AdminService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Extensions.Logging" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" /> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore\LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="appsettings.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,43 @@ |
|||
using LINGYUN.Abp.MicroService.AdminService; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
using System; |
|||
|
|||
var defaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"; |
|||
|
|||
Log.Logger = new LoggerConfiguration() |
|||
.MinimumLevel.Information() |
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|||
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
|||
#if DEBUG
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.AdminService", LogEventLevel.Debug) |
|||
#else
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.AdminService", LogEventLevel.Information) |
|||
#endif
|
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(x => x.Console(outputTemplate: defaultOutputTemplate)) |
|||
.WriteTo.Async(x => x.File("Logs/migrations.txt", outputTemplate: defaultOutputTemplate)) |
|||
.CreateLogger(); |
|||
|
|||
try |
|||
{ |
|||
var builder = Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<AdminServiceDbMigratorHostedService>(); |
|||
}); |
|||
await builder.RunConsoleAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EntityFrameworkCore.Migrations; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
public class AdminServiceDbMigrationEventHandler : EfCoreDatabaseMigrationEventHandlerBase<AdminServiceMigrationsDbContext> |
|||
{ |
|||
protected IDataSeeder DataSeeder { get; } |
|||
|
|||
public AdminServiceDbMigrationEventHandler( |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
ITenantStore tenantStore, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory, |
|||
IDataSeeder dataSeeder) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<AdminServiceMigrationsDbContext>(), |
|||
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
DataSeeder = dataSeeder; |
|||
} |
|||
|
|||
protected async override Task SeedAsync(Guid? tenantId) |
|||
{ |
|||
await DataSeeder.SeedAsync(tenantId); |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
public class AdminServiceDbMigrationService : EfCoreRuntimeDbMigratorBase<AdminServiceMigrationsDbContext>, ITransientDependency |
|||
{ |
|||
public AdminServiceDbMigrationService( |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
IServiceProvider serviceProvider, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<AdminServiceMigrationsDbContext>(), |
|||
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
using LINGYUN.Abp.DataProtectionManagement; |
|||
using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Saas.Editions; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Saas.Tenants; |
|||
using LINGYUN.Abp.TextTemplating; |
|||
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
[ConnectionStringName("Default")] |
|||
public class AdminServiceMigrationsDbContext : |
|||
AbpDbContext<AdminServiceMigrationsDbContext>, |
|||
ISaasDbContext, |
|||
ITextTemplatingDbContext, |
|||
IFeatureManagementDbContext, |
|||
ISettingManagementDbContext, |
|||
IPermissionManagementDbContext, |
|||
IAbpDataProtectionManagementDbContext |
|||
{ |
|||
#region Entities from the modules
|
|||
|
|||
public DbSet<EntityTypeInfo> EntityTypeInfos { get; set; } |
|||
|
|||
public DbSet<PermissionGroupDefinitionRecord> PermissionGroups { get; set; } |
|||
|
|||
public DbSet<PermissionDefinitionRecord> Permissions { get; set; } |
|||
|
|||
public DbSet<PermissionGrant> PermissionGrants { get; set; } |
|||
|
|||
public DbSet<Setting> Settings { get; set; } |
|||
|
|||
public DbSet<SettingDefinitionRecord> SettingDefinitionRecords { get; set; } |
|||
|
|||
public DbSet<FeatureGroupDefinitionRecord> FeatureGroups { get; set; } |
|||
|
|||
public DbSet<FeatureDefinitionRecord> Features { get; set; } |
|||
|
|||
public DbSet<FeatureValue> FeatureValues { get; set; } |
|||
|
|||
public DbSet<TextTemplate> TextTemplates { get; set; } |
|||
|
|||
public DbSet<TextTemplateDefinition> TextTemplateDefinitions { get; set; } |
|||
|
|||
public DbSet<Edition> Editions { get; set; } |
|||
|
|||
public DbSet<Tenant> Tenants { get; set; } |
|||
|
|||
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; } |
|||
|
|||
#endregion
|
|||
|
|||
public AdminServiceMigrationsDbContext(DbContextOptions<AdminServiceMigrationsDbContext> options) |
|||
: base(options) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureSaas(); |
|||
modelBuilder.ConfigureTextTemplating(); |
|||
modelBuilder.ConfigureFeatureManagement(); |
|||
modelBuilder.ConfigureSettingManagement(); |
|||
modelBuilder.ConfigurePermissionManagement(); |
|||
modelBuilder.ConfigureDataProtectionManagement(); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.IO; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
public class AdminServiceMigrationsDbContextFactory : IDesignTimeDbContextFactory<AdminServiceMigrationsDbContext> |
|||
{ |
|||
public AdminServiceMigrationsDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
var connectionString = configuration.GetConnectionString("Default"); |
|||
|
|||
var builder = new DbContextOptionsBuilder<AdminServiceMigrationsDbContext>() |
|||
.UseNpgsql(connectionString); |
|||
|
|||
return new AdminServiceMigrationsDbContext(builder!.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../LINGYUN.Abp.MicroService.AdminService.DbMigrator/")) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
@ -0,0 +1,93 @@ |
|||
using LINGYUN.Abp.Account; |
|||
using LINGYUN.Abp.Auditing; |
|||
using LINGYUN.Abp.CachingManagement; |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.DataProtectionManagement; |
|||
using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.FeatureManagement; |
|||
using LINGYUN.Abp.Gdpr; |
|||
using LINGYUN.Abp.Identity; |
|||
using LINGYUN.Abp.Identity.EntityFrameworkCore; |
|||
using LINGYUN.Abp.IdentityServer; |
|||
using LINGYUN.Abp.LocalizationManagement; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.MessageService; |
|||
using LINGYUN.Abp.Notifications; |
|||
using LINGYUN.Abp.OpenIddict; |
|||
using LINGYUN.Abp.OssManagement; |
|||
using LINGYUN.Abp.ProjectManagement; |
|||
using LINGYUN.Abp.RulesEngineManagement; |
|||
using LINGYUN.Abp.Saas; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using LINGYUN.Abp.SettingManagement; |
|||
using LINGYUN.Abp.TaskManagement; |
|||
using LINGYUN.Abp.TextTemplating; |
|||
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
|||
using LINGYUN.Abp.WebhooksManagement; |
|||
using LINGYUN.Platform; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.PostgreSql; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSettingManagementApplicationContractsModule), |
|||
typeof(AbpAccountApplicationContractsModule), |
|||
typeof(AbpAuditingApplicationContractsModule), |
|||
typeof(AbpCachingManagementApplicationContractsModule), |
|||
typeof(AbpDataProtectionManagementApplicationContractsModule), |
|||
typeof(AbpFeatureManagementApplicationContractsModule), |
|||
typeof(AbpGdprApplicationContractsModule), |
|||
typeof(AbpIdentityApplicationContractsModule), |
|||
typeof(AbpIdentityServerApplicationContractsModule), |
|||
typeof(AbpLocalizationManagementApplicationContractsModule), |
|||
typeof(AbpOpenIddictApplicationContractsModule), |
|||
typeof(AbpOssManagementApplicationContractsModule), |
|||
typeof(AbpPermissionManagementApplicationContractsModule), |
|||
typeof(PlatformApplicationContractModule), |
|||
typeof(AbpProjectManagementApplicationContractsModule), |
|||
typeof(AbpMessageServiceApplicationContractsModule), |
|||
typeof(AbpNotificationsApplicationContractsModule), |
|||
typeof(RulesEngineManagementApplicationContractsModule), |
|||
typeof(AbpSaasApplicationContractsModule), |
|||
typeof(TaskManagementApplicationContractsModule), |
|||
typeof(AbpTextTemplatingApplicationContractsModule), |
|||
typeof(WebhooksManagementApplicationContractsModule))] |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSaasEntityFrameworkCoreModule), |
|||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|||
typeof(AbpDataProtectionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
|||
typeof(AbpIdentityEntityFrameworkCoreModule),// 用户角色权限需要引用包
|
|||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
|||
typeof(AbpTextTemplatingEntityFrameworkCoreModule), |
|||
typeof(AbpEntityFrameworkCorePostgreSqlModule), |
|||
typeof(AbpDataDbMigratorModule) |
|||
)] |
|||
public class AdminServiceMigrationsEntityFrameworkCoreModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAbpDbContext<AdminServiceMigrationsDbContext>(); |
|||
|
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.UseNpgsql(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,61 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<IsPackable>false</IsPackable> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AdminService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\settings\LINGYUN.Abp.SettingManagement.Application.Contracts\LINGYUN.Abp.SettingManagement.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application.Contracts\LINGYUN.Abp.Account.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\auditing\LINGYUN.Abp.Auditing.Application.Contracts\LINGYUN.Abp.Auditing.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\caching-management\LINGYUN.Abp.CachingManagement.Application.Contracts\LINGYUN.Abp.CachingManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application.Contracts\LINGYUN.Abp.DataProtectionManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\feature-management\LINGYUN.Abp.FeatureManagement.Application.Contracts\LINGYUN.Abp.FeatureManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.Application.Contracts\LINGYUN.Abp.Gdpr.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.Application.Contracts\LINGYUN.Abp.IdentityServer.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.Application.Contracts\LINGYUN.Abp.LocalizationManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.Application.Contracts\LINGYUN.Abp.OpenIddict.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Application.Contracts\LINGYUN.Abp.OssManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\permissions-management\LINGYUN.Abp.PermissionManagement.Application.Contracts\LINGYUN.Abp.PermissionManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Platform.Application.Contracts\LINGYUN.Platform.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\project\LINGYUN.Abp.ProjectManagement.Application.Contracts\LINGYUN.Abp.ProjectManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\realtime-message\LINGYUN.Abp.MessageService.Application.Contracts\LINGYUN.Abp.MessageService.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Application.Contracts\LINGYUN.Abp.Notifications.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\rules-management\rules-engine\LINGYUN.Abp.RulesEngineManagement.Application.Contracts\LINGYUN.Abp.RulesEngineManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.Application.Contracts\LINGYUN.Abp.Saas.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.Application.Contracts\LINGYUN.Abp.TaskManagement.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.Application.Contracts\LINGYUN.Abp.TextTemplating.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\webhooks\LINGYUN.Abp.WebhooksManagement.Application.Contracts\LINGYUN.Abp.WebhooksManagement.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\modules\data-protection\LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore\LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
File diff suppressed because it is too large
@ -0,0 +1,583 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class Initial_Admin_Service : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthEntitites", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
TypeFullName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
IsAuditEnabled = table.Column<bool>(type: "boolean", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthEntitites", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthSubjectStrategys", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
SubjectName = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false), |
|||
SubjectId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
Strategy = table.Column<int>(type: "integer", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthSubjectStrategys", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpEditions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
EntityVersion = table.Column<int>(type: "integer", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpEditions", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpFeatureGroups", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpFeatureGroups", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpFeatures", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
GroupName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
ParentName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true), |
|||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
Description = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
DefaultValue = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
IsVisibleToClients = table.Column<bool>(type: "boolean", nullable: false), |
|||
IsAvailableToHost = table.Column<bool>(type: "boolean", nullable: false), |
|||
AllowedProviders = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
ValueType = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpFeatures", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpFeatureValues", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Value = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
ProviderName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
ProviderKey = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpPermissionGrants", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
ProviderName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
ProviderKey = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpPermissionGroups", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpPermissionGroups", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpPermissions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
GroupName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
ParentName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true), |
|||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false), |
|||
MultiTenancySide = table.Column<byte>(type: "smallint", nullable: false), |
|||
Providers = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true), |
|||
StateCheckers = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpPermissions", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpSettingDefinitions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
Description = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true), |
|||
DefaultValue = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true), |
|||
IsVisibleToClients = table.Column<bool>(type: "boolean", nullable: false), |
|||
Providers = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true), |
|||
IsInherited = table.Column<bool>(type: "boolean", nullable: false), |
|||
IsEncrypted = table.Column<bool>(type: "boolean", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpSettingDefinitions", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpSettings", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Value = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false), |
|||
ProviderName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
ProviderKey = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpSettings", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpTextTemplateDefinitions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false), |
|||
IsLayout = table.Column<bool>(type: "boolean", nullable: false), |
|||
Layout = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true), |
|||
IsInlineLocalized = table.Column<bool>(type: "boolean", nullable: false), |
|||
DefaultCultureName = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true), |
|||
LocalizationResourceName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
RenderEngine = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true), |
|||
IsStatic = table.Column<bool>(type: "boolean", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpTextTemplateDefinitions", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpTextTemplates", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), |
|||
Content = table.Column<string>(type: "character varying(1048576)", maxLength: 1048576, nullable: true), |
|||
Culture = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpTextTemplates", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthEntityProperties", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
TypeFullName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
JavaScriptType = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
TypeInfoId = table.Column<Guid>(type: "uuid", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthEntityProperties", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpAuthEntityProperties_AbpAuthEntitites_TypeInfoId", |
|||
column: x => x.TypeInfoId, |
|||
principalTable: "AbpAuthEntitites", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthOrganizationUnitEntityRules", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrgId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrgCode = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false), |
|||
Operation = table.Column<int>(type: "integer", nullable: false), |
|||
FilterGroup = table.Column<string>(type: "text", nullable: true), |
|||
EntityTypeId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
EntityTypeFullName = table.Column<string>(type: "text", nullable: true), |
|||
AccessedProperties = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthOrganizationUnitEntityRules", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpAuthOrganizationUnitEntityRules_AbpAuthEntitites_EntityT~", |
|||
column: x => x.EntityTypeId, |
|||
principalTable: "AbpAuthEntitites", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthRoleEntityRules", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
RoleId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
RoleName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false), |
|||
Operation = table.Column<int>(type: "integer", nullable: false), |
|||
FilterGroup = table.Column<string>(type: "text", nullable: true), |
|||
EntityTypeId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
EntityTypeFullName = table.Column<string>(type: "text", nullable: true), |
|||
AccessedProperties = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthRoleEntityRules", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpAuthRoleEntityRules_AbpAuthEntitites_EntityTypeId", |
|||
column: x => x.EntityTypeId, |
|||
principalTable: "AbpAuthEntitites", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpTenants", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
NormalizedName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
IsActive = table.Column<bool>(type: "boolean", nullable: false), |
|||
EnableTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
DisableTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
EditionId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
EntityVersion = table.Column<int>(type: "integer", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpTenants", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpTenants_AbpEditions_EditionId", |
|||
column: x => x.EditionId, |
|||
principalTable: "AbpEditions", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpAuthEntityEnums", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Value = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false), |
|||
PropertyInfoId = table.Column<Guid>(type: "uuid", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpAuthEntityEnums", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpAuthEntityEnums_AbpAuthEntityProperties_PropertyInfoId", |
|||
column: x => x.PropertyInfoId, |
|||
principalTable: "AbpAuthEntityProperties", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpTenantConnectionStrings", |
|||
columns: table => new |
|||
{ |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
Value = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", |
|||
column: x => x.TenantId, |
|||
principalTable: "AbpTenants", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpAuthEntitites_TypeFullName", |
|||
table: "AbpAuthEntitites", |
|||
column: "TypeFullName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpAuthEntityEnums_PropertyInfoId_Name", |
|||
table: "AbpAuthEntityEnums", |
|||
columns: new[] { "PropertyInfoId", "Name" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpAuthEntityProperties_TypeInfoId_TypeFullName", |
|||
table: "AbpAuthEntityProperties", |
|||
columns: new[] { "TypeInfoId", "TypeFullName" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpAuthOrganizationUnitEntityRules_EntityTypeId", |
|||
table: "AbpAuthOrganizationUnitEntityRules", |
|||
column: "EntityTypeId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpAuthRoleEntityRules_EntityTypeId", |
|||
table: "AbpAuthRoleEntityRules", |
|||
column: "EntityTypeId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpEditions_DisplayName", |
|||
table: "AbpEditions", |
|||
column: "DisplayName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpFeatureGroups_Name", |
|||
table: "AbpFeatureGroups", |
|||
column: "Name", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpFeatures_GroupName", |
|||
table: "AbpFeatures", |
|||
column: "GroupName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpFeatures_Name", |
|||
table: "AbpFeatures", |
|||
column: "Name", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", |
|||
table: "AbpFeatureValues", |
|||
columns: new[] { "Name", "ProviderName", "ProviderKey" }, |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", |
|||
table: "AbpPermissionGrants", |
|||
columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpPermissionGroups_Name", |
|||
table: "AbpPermissionGroups", |
|||
column: "Name", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpPermissions_GroupName", |
|||
table: "AbpPermissions", |
|||
column: "GroupName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpPermissions_Name", |
|||
table: "AbpPermissions", |
|||
column: "Name", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSettingDefinitions_Name", |
|||
table: "AbpSettingDefinitions", |
|||
column: "Name", |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSettings_Name_ProviderName_ProviderKey", |
|||
table: "AbpSettings", |
|||
columns: new[] { "Name", "ProviderName", "ProviderKey" }, |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpTenants_EditionId", |
|||
table: "AbpTenants", |
|||
column: "EditionId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpTenants_Name", |
|||
table: "AbpTenants", |
|||
column: "Name"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpTenants_NormalizedName", |
|||
table: "AbpTenants", |
|||
column: "NormalizedName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_Tenant_Text_Template_Name", |
|||
table: "AbpTextTemplates", |
|||
column: "Name"); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthEntityEnums"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthOrganizationUnitEntityRules"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthRoleEntityRules"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthSubjectStrategys"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpFeatureGroups"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpFeatures"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpFeatureValues"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpPermissionGrants"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpPermissionGroups"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpPermissions"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpSettingDefinitions"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpSettings"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpTenantConnectionStrings"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpTextTemplateDefinitions"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpTextTemplates"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthEntityProperties"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpTenants"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpAuthEntitites"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpEditions"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,437 @@ |
|||
using DotNetCore.CAP; |
|||
using LINGYUN.Abp.DataProtectionManagement; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.LocalizationManagement; |
|||
using LINGYUN.Abp.Saas; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.TextTemplating; |
|||
using LINGYUN.Abp.Wrapper; |
|||
using Medallion.Threading; |
|||
using Medallion.Threading.Redis; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.Cors; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.Extensions.Caching.StackExchangeRedis; |
|||
using Microsoft.IdentityModel.Logging; |
|||
using Microsoft.IdentityModel.Tokens; |
|||
using Microsoft.OpenApi.Models; |
|||
using StackExchange.Redis; |
|||
using System.Text.Encodings.Web; |
|||
using System.Text.Unicode; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.AntiForgery; |
|||
using Volo.Abp.Auditing; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
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.Json; |
|||
using Volo.Abp.Json.SystemTextJson; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Security.Claims; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.Timing; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
public partial class AdminServiceModule |
|||
{ |
|||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
|||
|
|||
private void PreConfigureFeature() |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureApp(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options => |
|||
{ |
|||
// 以开放端口区别,应在0-31之间
|
|||
options.SnowflakeIdOptions.WorkerId = 10; |
|||
options.SnowflakeIdOptions.WorkerIdBits = 5; |
|||
options.SnowflakeIdOptions.DatacenterId = 1; |
|||
}); |
|||
|
|||
if (configuration.GetValue<bool>("App:ShowPii")) |
|||
{ |
|||
IdentityModelEventSource.ShowPII = true; |
|||
} |
|||
} |
|||
|
|||
private void PreConfigureCAP(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<CapOptions>(options => |
|||
{ |
|||
options |
|||
.UsePostgreSql(mySqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:PostgreSql").Bind(mySqlOptions); |
|||
}) |
|||
.UseRabbitMQ(rabbitMQOptions => |
|||
{ |
|||
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
|||
}) |
|||
.UseDashboard(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureTextTemplating() |
|||
{ |
|||
Configure<AbpTextTemplatingCachingOptions>(options => |
|||
{ |
|||
options.IsDynamicTemplateDefinitionStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureFeatureManagement() |
|||
{ |
|||
Configure<FeatureManagementOptions>(options => |
|||
{ |
|||
options.ProviderPolicies[EditionFeatureValueProvider.ProviderName] = AbpSaasPermissions.Editions.ManageFeatures; |
|||
options.ProviderPolicies[TenantFeatureValueProvider.ProviderName] = AbpSaasPermissions.Tenants.ManageFeatures; |
|||
|
|||
options.IsDynamicFeatureStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureJsonSerializer(IConfiguration configuration) |
|||
{ |
|||
// 统一时间日期格式
|
|||
Configure<AbpJsonOptions>(options => |
|||
{ |
|||
var jsonConfiguration = configuration.GetSection("Json"); |
|||
if (jsonConfiguration.Exists()) |
|||
{ |
|||
jsonConfiguration.Bind(options); |
|||
} |
|||
}); |
|||
// 中文序列化的编码问题
|
|||
Configure<AbpSystemTextJsonSerializerOptions>(options => |
|||
{ |
|||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigurePermissionManagement() |
|||
{ |
|||
Configure<PermissionManagementOptions>(options => |
|||
{ |
|||
options.IsDynamicPermissionStoreEnabled = true; |
|||
// 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] = "AbpOpenIddict.Applications.ManagePermissions"; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDataProtectedManagement() |
|||
{ |
|||
Configure<DataProtectionManagementOptions>(options => |
|||
{ |
|||
//options.AddEntities(typeof(IdentityResource), new Type[]
|
|||
//{
|
|||
// typeof(IdentityUser),
|
|||
// typeof(IdentityRole),
|
|||
// typeof(OrganizationUnit),
|
|||
//});
|
|||
|
|||
//options.AddEntities(typeof(IdentityResource), new Type[]
|
|||
//{
|
|||
// typeof(IdentityUser),
|
|||
// typeof(IdentityRole),
|
|||
// typeof(OrganizationUnit),
|
|||
//});
|
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSettingManagement() |
|||
{ |
|||
Configure<SettingManagementOptions>(options => |
|||
{ |
|||
options.IsDynamicSettingStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureTiming(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpClockOptions>(options => |
|||
{ |
|||
configuration.GetSection("Clock").Bind(options); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCaching(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpDistributedCacheOptions>(options => |
|||
{ |
|||
configuration.GetSection("DistributedCache").Bind(options); |
|||
}); |
|||
|
|||
Configure<AbpDistributedEntityEventOptions>(options => |
|||
{ |
|||
options.AutoEventSelectors.AddNamespace("Volo.Abp.TenantManagement"); |
|||
}); |
|||
|
|||
Configure<RedisCacheOptions>(options => |
|||
{ |
|||
var redisConfig = ConfigurationOptions.Parse(options.Configuration!); |
|||
options.ConfigurationOptions = redisConfig; |
|||
options.InstanceName = configuration["Redis:InstanceName"]; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDistributedLocking(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
var distributedLockEnabled = configuration["DistributedLock:IsEnabled"]; |
|||
if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) |
|||
{ |
|||
services.AddSingleton<IDistributedLockProvider>(sp => |
|||
{ |
|||
var connectionMultiplexer = sp.GetRequiredService<IConnectionMultiplexer>(); |
|||
return new RedisDistributedSynchronizationProvider(connectionMultiplexer.GetDatabase()); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureMvc(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAspNetCoreMvcOptions>(options => |
|||
{ |
|||
options.ExposeIntegrationServices = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureVirtualFileSystem() |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AdminServiceModule>("LINGYUN.Abp.MicroService.AdminService"); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureMultiTenancy(IConfiguration configuration) |
|||
{ |
|||
// 多租户
|
|||
Configure<AbpMultiTenancyOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
|
|||
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
|||
if (tenantResolveCfg.Exists()) |
|||
{ |
|||
Configure<AbpTenantResolveOptions>(options => |
|||
{ |
|||
var domains = tenantResolveCfg.Get<string[]>() ?? []; |
|||
foreach (var domain in domains) |
|||
{ |
|||
options.AddDomainTenantResolver(domain); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureIdentity(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
options.IsDynamicClaimsEnabled = true; |
|||
options.RemoteRefreshUrl = configuration["App:RefreshClaimsUrl"] + options.RemoteRefreshUrl; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAuditing(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
// 是否启用实体变更记录
|
|||
var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; |
|||
if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || |
|||
(bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) |
|||
{ |
|||
options.EntityHistorySelectors.AddAllEntities(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
// Swagger
|
|||
services.AddAbpSwaggerGenWithOAuth( |
|||
configuration["AuthServer:Authority"]!, |
|||
new Dictionary<string, string> |
|||
{ |
|||
{ "AdminService", "Admin Service API"} |
|||
}, |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo |
|||
{ |
|||
Title = "Admin Service API", Version = "v1", |
|||
Contact = new OpenApiContact |
|||
{ |
|||
Name = "colin", |
|||
Email = "colin.in@foxmail.com", |
|||
Url = new Uri("https://github.com/colinin") |
|||
}, |
|||
License = new OpenApiLicense |
|||
{ |
|||
Name = "MIT", |
|||
Url = new Uri("https://github.com/colinin/abp-next-admin/blob/master/LICENSE") |
|||
} |
|||
}); |
|||
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<TenantHeaderParamter>(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureLocalization() |
|||
{ |
|||
// 支持本地化语言类型
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
|||
|
|||
options.Resources |
|||
.Get<IdentityResource>() |
|||
.AddVirtualJson("/Localization/Resources"); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationCultureMapOptions>(options => |
|||
{ |
|||
var zhHansCultureMapInfo = new CultureMapInfo |
|||
{ |
|||
TargetCulture = "zh-Hans", |
|||
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
|||
}; |
|||
|
|||
options.CulturesMaps.Add(zhHansCultureMapInfo); |
|||
options.UiCulturesMaps.Add(zhHansCultureMapInfo); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationManagementOptions>(options => |
|||
{ |
|||
options.SaveStaticLocalizationsToDatabase = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCors(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
services.AddCors(options => |
|||
{ |
|||
options.AddDefaultPolicy(builder => |
|||
{ |
|||
var corsOrigins = configuration.GetSection("App:CorsOrigins").Get<List<string>>(); |
|||
if (corsOrigins == null || corsOrigins.Count == 0) |
|||
{ |
|||
corsOrigins = configuration["App:CorsOrigins"]? |
|||
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToList() ?? new List<string>(); |
|||
} |
|||
builder |
|||
.WithOrigins(corsOrigins |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToArray() |
|||
) |
|||
.WithAbpExposedHeaders() |
|||
.WithAbpWrapExposedHeaders() |
|||
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|||
.AllowAnyHeader() |
|||
.AllowAnyMethod() |
|||
.AllowCredentials(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
|||
{ |
|||
Configure<AbpAntiForgeryOptions>(options => |
|||
{ |
|||
options.TokenCookie.HttpOnly = false; |
|||
options.TokenCookie.SameSite = SameSiteMode.Lax; |
|||
}); |
|||
|
|||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
|||
.AddAbpJwtBearer(options => |
|||
{ |
|||
configuration.GetSection("AuthServer").Bind(options); |
|||
|
|||
var validIssuers = configuration.GetSection("AuthServer:ValidIssuers").Get<List<string>>(); |
|||
if (validIssuers?.Count > 0) |
|||
{ |
|||
options.TokenValidationParameters.ValidIssuers = validIssuers; |
|||
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator; |
|||
} |
|||
var validAudiences = configuration.GetSection("AuthServer:ValidAudiences").Get<List<string>>(); |
|||
if (validAudiences?.Count > 0) |
|||
{ |
|||
options.TokenValidationParameters.ValidAudiences = validAudiences; |
|||
} |
|||
}); |
|||
|
|||
services |
|||
.AddDataProtection() |
|||
.SetApplicationName("LINGYUN.Abp.Application") |
|||
.PersistKeysToStackExchangeRedis(() => |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); |
|||
|
|||
return redis.GetDatabase(); |
|||
}, |
|||
"LINGYUN.Abp.Application:DataProtection:Protection-Keys"); |
|||
} |
|||
|
|||
private void ConfigureWrapper() |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureWrapper() |
|||
{ |
|||
// 服务间调用不包装
|
|||
PreConfigure<AbpHttpClientBuilderOptions>(options => |
|||
{ |
|||
options.ProxyClientActions.Add( |
|||
(_, _, client) => |
|||
{ |
|||
client.DefaultRequestHeaders.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,157 @@ |
|||
using LINGYUN.Abp.Aliyun.SettingManagement; |
|||
using LINGYUN.Abp.AspNetCore.HttpOverrides; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Localization; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; |
|||
using LINGYUN.Abp.Auditing; |
|||
using LINGYUN.Abp.AuditLogging.Elasticsearch; |
|||
using LINGYUN.Abp.CachingManagement; |
|||
using LINGYUN.Abp.CachingManagement.StackExchangeRedis; |
|||
using LINGYUN.Abp.Claims.Mapping; |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.DataProtectionManagement; |
|||
using LINGYUN.Abp.Emailing.Platform; |
|||
using LINGYUN.Abp.EventBus.CAP; |
|||
using LINGYUN.Abp.ExceptionHandling.Emailing; |
|||
using LINGYUN.Abp.FeatureManagement; |
|||
using LINGYUN.Abp.FeatureManagement.HttpApi; |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.Logging.Serilog.Elasticsearch; |
|||
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.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.SettingManagement; |
|||
using LINGYUN.Abp.Sms.Platform; |
|||
using LINGYUN.Abp.Tencent.SettingManagement; |
|||
using LINGYUN.Abp.TextTemplating; |
|||
using LINGYUN.Abp.TextTemplating.Scriban; |
|||
using LINGYUN.Abp.WxPusher.SettingManagement; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Caching.StackExchangeRedis; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.Identity; |
|||
using Volo.Abp.PermissionManagement.OpenIddict; |
|||
using Volo.Abp.Swashbuckle; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpCAPEventBusModule), |
|||
typeof(AbpSerilogEnrichersApplicationModule), |
|||
typeof(AbpSerilogEnrichersUniqueIdModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpLoggingSerilogElasticsearchModule), |
|||
typeof(AbpAuditLoggingElasticsearchModule), |
|||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule), |
|||
typeof(AbpAspNetCoreMvcLocalizationModule), |
|||
|
|||
// 设置管理
|
|||
typeof(AbpAliyunSettingManagementModule), |
|||
typeof(AbpTencentCloudSettingManagementModule), |
|||
// typeof(AbpWeChatSettingManagementModule),
|
|||
typeof(AbpWxPusherSettingManagementModule), |
|||
typeof(AbpOssManagementSettingManagementModule), |
|||
|
|||
typeof(AbpSettingManagementApplicationModule), |
|||
typeof(AbpSettingManagementHttpApiModule), |
|||
typeof(AbpPermissionManagementApplicationModule), |
|||
typeof(AbpPermissionManagementHttpApiModule), |
|||
typeof(AbpDataProtectionManagementApplicationModule), |
|||
typeof(AbpDataProtectionManagementHttpApiModule), |
|||
typeof(AbpFeatureManagementApplicationModule), |
|||
typeof(AbpFeatureManagementHttpApiModule), |
|||
typeof(AbpFeatureManagementClientModule), |
|||
typeof(AbpAuditingApplicationModule), |
|||
typeof(AbpAuditingHttpApiModule), |
|||
typeof(AbpSaasApplicationModule), |
|||
typeof(AbpSaasHttpApiModule), |
|||
typeof(AbpSaasDbCheckerModule), |
|||
typeof(AbpTextTemplatingApplicationModule), |
|||
typeof(AbpTextTemplatingHttpApiModule), |
|||
typeof(AbpCachingManagementApplicationModule), |
|||
typeof(AbpCachingManagementHttpApiModule), |
|||
typeof(AbpCachingManagementStackExchangeRedisModule), |
|||
typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理
|
|||
typeof(AbpPermissionManagementDomainIdentityModule), |
|||
typeof(AbpPermissionManagementDomainOpenIddictModule), |
|||
|
|||
// 重写模板引擎支持外部本地化
|
|||
typeof(AbpTextTemplatingScribanModule), |
|||
|
|||
typeof(AbpIdentitySessionAspNetCoreModule), |
|||
|
|||
typeof(AdminServiceMigrationsEntityFrameworkCoreModule), |
|||
typeof(AbpDataDbMigratorModule), |
|||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
|||
typeof(AbpEmailingExceptionHandlingModule), |
|||
typeof(AbpHttpClientModule), |
|||
typeof(AbpSmsPlatformModule), |
|||
typeof(AbpEmailingPlatformModule), |
|||
typeof(AbpCachingStackExchangeRedisModule), |
|||
typeof(AbpLocalizationCultureMapModule), |
|||
typeof(AbpAspNetCoreMvcWrapperModule), |
|||
typeof(AbpAspNetCoreHttpOverridesModule), |
|||
typeof(AbpClaimsMappingModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpAutofacModule) |
|||
)] |
|||
public partial class AdminServiceModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
PreConfigureWrapper(); |
|||
PreConfigureFeature(); |
|||
PreConfigureApp(configuration); |
|||
PreConfigureCAP(configuration); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
ConfigureWrapper(); |
|||
ConfigureLocalization(); |
|||
ConfigureVirtualFileSystem(); |
|||
ConfigureTextTemplating(); |
|||
ConfigureSettingManagement(); |
|||
ConfigureFeatureManagement(); |
|||
ConfigurePermissionManagement(); |
|||
ConfigureDataProtectedManagement(); |
|||
ConfigureIdentity(configuration); |
|||
ConfigureTiming(configuration); |
|||
ConfigureCaching(configuration); |
|||
ConfigureAuditing(configuration); |
|||
ConfigureMultiTenancy(configuration); |
|||
ConfigureJsonSerializer(configuration); |
|||
ConfigureMvc(context.Services, configuration); |
|||
ConfigureCors(context.Services, configuration); |
|||
ConfigureSwagger(context.Services, configuration); |
|||
ConfigureDistributedLocking(context.Services, configuration); |
|||
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); |
|||
} |
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); |
|||
} |
|||
|
|||
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|||
{ |
|||
await context.ServiceProvider |
|||
.GetRequiredService<IDataSeeder>() |
|||
.SeedAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AdminService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AgileConfig.Client" /> |
|||
<PackageReference Include="DotNetCore.CAP.Dashboard" /> |
|||
<PackageReference Include="DotNetCore.CAP.PostgreSql" /> |
|||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" /> |
|||
<PackageReference Include="DistributedLock.Redis" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> |
|||
<PackageReference Include="Serilog.AspNetCore" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" /> |
|||
<PackageReference Include="Volo.Abp.Http.Client" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Application" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.OpenIddict" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\cloud-aliyun\LINGYUN.Abp.Aliyun.SettingManagement\LINGYUN.Abp.Aliyun.SettingManagement.csproj" /> |
|||
<ProjectReference Include="..\..\framework\cloud-tencent\LINGYUN.Abp.Tencent.SettingManagement\LINGYUN.Abp.Tencent.SettingManagement.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.ExceptionHandling.Emailing\LINGYUN.Abp.ExceptionHandling.Emailing.csproj" /> |
|||
<ProjectReference Include="..\..\framework\features\LINGYUN.Abp.FeatureManagement.Client\LINGYUN.Abp.FeatureManagement.Client.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.AspNetCore.Mvc.Localization\LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.Localization.CultureMap\LINGYUN.Abp.Localization.CultureMap.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Logging.Serilog.Elasticsearch\LINGYUN.Abp.Logging.Serilog.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.Application\LINGYUN.Abp.Serilog.Enrichers.Application.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" /> |
|||
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" /> |
|||
<ProjectReference Include="..\..\framework\security\LINGYUN.Abp.Claims.Mapping\LINGYUN.Abp.Claims.Mapping.csproj" /> |
|||
<ProjectReference Include="..\..\framework\wx-pusher\LINGYUN.Abp.WxPusher.SettingManagement\LINGYUN.Abp.WxPusher.SettingManagement.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore\LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\auditing\LINGYUN.Abp.Auditing.Application\LINGYUN.Abp.Auditing.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\auditing\LINGYUN.Abp.Auditing.HttpApi\LINGYUN.Abp.Auditing.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\caching-management\LINGYUN.Abp.CachingManagement.Application\LINGYUN.Abp.CachingManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\caching-management\LINGYUN.Abp.CachingManagement.HttpApi\LINGYUN.Abp.CachingManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\caching-management\LINGYUN.Abp.CachingManagement.StackExchangeRedis\LINGYUN.Abp.CachingManagement.StackExchangeRedis.csproj" /> |
|||
<ProjectReference Include="..\..\modules\data-protection\LINGYUN.Abp.DataProtectionManagement.Application\LINGYUN.Abp.DataProtectionManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\data-protection\LINGYUN.Abp.DataProtectionManagement.HttpApi\LINGYUN.Abp.DataProtectionManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\feature-management\LINGYUN.Abp.FeatureManagement.Application\LINGYUN.Abp.FeatureManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\feature-management\LINGYUN.Abp.FeatureManagement.HttpApi\LINGYUN.Abp.FeatureManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Session.AspNetCore\LINGYUN.Abp.Identity.Session.AspNetCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.OssManagement.SettingManagement\LINGYUN.Abp.OssManagement.SettingManagement.csproj" /> |
|||
<ProjectReference Include="..\..\modules\permissions-management\LINGYUN.Abp.PermissionManagement.Application\LINGYUN.Abp.PermissionManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\permissions-management\LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits\LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits.csproj" /> |
|||
<ProjectReference Include="..\..\modules\permissions-management\LINGYUN.Abp.PermissionManagement.HttpApi\LINGYUN.Abp.PermissionManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Emailing.Platform\LINGYUN.Abp.Emailing.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Sms.Platform\LINGYUN.Abp.Sms.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.Application\LINGYUN.Abp.Saas.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.DbChecker\LINGYUN.Abp.Saas.DbChecker.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.HttpApi\LINGYUN.Abp.Saas.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\settings\LINGYUN.Abp.SettingManagement.Application\LINGYUN.Abp.SettingManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\settings\LINGYUN.Abp.SettingManagement.HttpApi\LINGYUN.Abp.SettingManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.Application\LINGYUN.Abp.TextTemplating.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.HttpApi\LINGYUN.Abp.TextTemplating.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.Scriban\LINGYUN.Abp.TextTemplating.Scriban.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ServiceDefaults\LINGYUN.Abp.MicroService.ServiceDefaults.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,119 @@ |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.MicroService.AdminService; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using Serilog; |
|||
using Volo.Abp.IO; |
|||
using Volo.Abp.Modularity.PlugIns; |
|||
|
|||
Log.Information("Starting AdminService Host..."); |
|||
|
|||
try |
|||
{ |
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.ConfigureAppConfiguration((context, config) => |
|||
{ |
|||
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) |
|||
{ |
|||
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); |
|||
} |
|||
}) |
|||
.UseSerilog((context, provider, config) => |
|||
{ |
|||
config.ReadFrom.Configuration(context.Configuration); |
|||
}); |
|||
|
|||
builder.AddServiceDefaults(); |
|||
|
|||
void LogConfig(IConfiguration config, int index = 0) |
|||
{ |
|||
var prefix = ""; |
|||
for (var i = 0; i < index; i++) |
|||
{ |
|||
prefix = "-" + prefix; |
|||
} |
|||
var children = config.GetChildren(); |
|||
if (children.Any()) |
|||
{ |
|||
foreach (var childrenConfig in children) |
|||
{ |
|||
Log.Logger.Information("{prefix}Config: {key}, Value: {value}", prefix, childrenConfig.Key, childrenConfig.Value); |
|||
LogConfig(childrenConfig, index + 1); |
|||
} |
|||
} |
|||
} |
|||
|
|||
LogConfig(builder.Configuration); |
|||
|
|||
await builder.AddApplicationAsync<AdminServiceModule>(options => |
|||
{ |
|||
var applicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME") ?? "AdminService"; |
|||
options.ApplicationName = applicationName; |
|||
AbpSerilogEnrichersConsts.ApplicationName = applicationName; |
|||
|
|||
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules"); |
|||
DirectoryHelper.CreateIfNotExists(pluginFolder); |
|||
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories); |
|||
}); |
|||
|
|||
var app = builder.Build(); |
|||
|
|||
await app.InitializeApplicationAsync(); |
|||
|
|||
app.MapDefaultEndpoints(); |
|||
|
|||
app.UseForwardedHeaders(); |
|||
// 本地化
|
|||
app.UseMapRequestLocalization(); |
|||
// http调用链
|
|||
app.UseCorrelationId(); |
|||
// 文件系统
|
|||
app.MapAbpStaticAssets(); |
|||
// 路由
|
|||
app.UseRouting(); |
|||
// 跨域
|
|||
app.UseCors(); |
|||
// 认证
|
|||
app.UseAuthentication(); |
|||
app.UseJwtTokenMiddleware(); |
|||
// 多租户
|
|||
app.UseMultiTenancy(); |
|||
// 会话
|
|||
app.UseAbpSession(); |
|||
// jwt
|
|||
app.UseDynamicClaims(); |
|||
// 授权
|
|||
app.UseAuthorization(); |
|||
// Swagger
|
|||
app.UseSwagger(); |
|||
// Swagger可视化界面
|
|||
app.UseAbpSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Admin Service API"); |
|||
|
|||
var configuration = app.Configuration; |
|||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); |
|||
options.OAuthScopes(configuration["AuthServer:Audience"]); |
|||
}); |
|||
// 审计日志
|
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
// 路由
|
|||
app.UseConfiguredEndpoints(); |
|||
|
|||
await app.RunAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
if (ex is HostAbortedException) |
|||
{ |
|||
throw; |
|||
} |
|||
|
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/launchsettings.json", |
|||
"profiles": { |
|||
"http": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": true, |
|||
"launchBrowser": false, |
|||
"applicationUrl": "http://localhost:5063", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Microsoft.OpenApi.Models; |
|||
using Swashbuckle.AspNetCore.SwaggerGen; |
|||
using Volo.Abp.AspNetCore.MultiTenancy; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AdminService; |
|||
|
|||
public class TenantHeaderParamter : IOperationFilter |
|||
{ |
|||
private readonly AbpMultiTenancyOptions _multiTenancyOptions; |
|||
private readonly AbpAspNetCoreMultiTenancyOptions _aspNetCoreMultiTenancyOptions; |
|||
public TenantHeaderParamter( |
|||
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
|||
IOptions<AbpAspNetCoreMultiTenancyOptions> aspNetCoreMultiTenancyOptions) |
|||
{ |
|||
_multiTenancyOptions = multiTenancyOptions.Value; |
|||
_aspNetCoreMultiTenancyOptions = aspNetCoreMultiTenancyOptions.Value; |
|||
} |
|||
|
|||
public void Apply(OpenApiOperation operation, OperationFilterContext context) |
|||
{ |
|||
if (_multiTenancyOptions.IsEnabled) |
|||
{ |
|||
operation.Parameters = operation.Parameters ?? new List<OpenApiParameter>(); |
|||
operation.Parameters.Add(new OpenApiParameter |
|||
{ |
|||
Name = _aspNetCoreMultiTenancyOptions.TenantKey, |
|||
In = ParameterLocation.Header, |
|||
Description = "Tenant Id in http header", |
|||
Required = false |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,115 @@ |
|||
{ |
|||
"App": { |
|||
"ShowPii": true, |
|||
"CorsOrigins": [ "http://localhost:5666", "http://localhost:30000" ], |
|||
"RefreshClaimsUrl": "http://localhost:30015" |
|||
}, |
|||
"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=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"CAP": { |
|||
"EventBus": { |
|||
"DefaultGroupName": "AdminService", |
|||
"Version": "v1", |
|||
"FailedRetryInterval": 300, |
|||
"FailedRetryCount": 10, |
|||
"CollectorCleaningInterval": 3600000 |
|||
}, |
|||
"PostgreSql": { |
|||
"TableNamePrefix": "admin", |
|||
"ConnectionString": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"RabbitMQ": { |
|||
"HostName": "localhost", |
|||
"Port": 5672, |
|||
"UserName": "admin", |
|||
"Password": "123456", |
|||
"ExchangeName": "LINGYUN.Abp.Application", |
|||
"VirtualHost": "/" |
|||
} |
|||
}, |
|||
"DistributedLock": { |
|||
"IsEnabled": true, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=13" |
|||
} |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=10", |
|||
"InstanceName": "LINGYUN.Abp.Application" |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://localhost:44385/", |
|||
"Audience": "lingyun-abp-application", |
|||
"MapInboundClaims": false, |
|||
"RequireHttpsMetadata": false, |
|||
"SwaggerClientId": "vue-oauth-client" |
|||
}, |
|||
"RemoteServices": { |
|||
"Platform": { |
|||
"BaseUrl": "http://localhost:30025", |
|||
"UseCurrentAccessToken": false |
|||
} |
|||
}, |
|||
"Logging": { |
|||
"Serilog": { |
|||
"Elasticsearch": { |
|||
"IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" |
|||
} |
|||
} |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://elasticsearch" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Debug" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"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://elasticsearch", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
{ |
|||
"Clock": { |
|||
"Kind": "Local" |
|||
}, |
|||
"Forwarded": { |
|||
"ForwardedHeaders": "XForwardedFor,XForwardedProto" |
|||
}, |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"Json": { |
|||
"InputDateTimeFormats": [ |
|||
"yyyy-MM-dd HH:mm:ss", |
|||
"yyyy-MM-ddTHH:mm:ss" |
|||
] |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Information" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,141 @@ |
|||
using Autofac.Core; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.Cors; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.AspNetCore.WebSockets; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.OpenApi.Models; |
|||
using StackExchange.Redis; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.ApiExploring; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Swashbuckle; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.ApiGateway; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSerilogEnrichersApplicationModule), |
|||
typeof(AbpSerilogEnrichersUniqueIdModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpDataModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpAspNetCoreMvcWrapperModule) |
|||
)] |
|||
public class ApiGatewayModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options => |
|||
{ |
|||
// 以开放端口区别
|
|||
options.SnowflakeIdOptions.WorkerId = 0; |
|||
options.SnowflakeIdOptions.WorkerIdBits = 5; |
|||
options.SnowflakeIdOptions.DatacenterId = 1; |
|||
}); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
|
|||
Configure<AbpAspNetCoreMvcOptions>(options => |
|||
{ |
|||
options.ControllersToRemove.Add(typeof(AbpApiDefinitionController)); |
|||
options.ControllersToRemove.Add(typeof(AbpApplicationLocalizationController)); |
|||
options.ControllersToRemove.Add(typeof(AbpApplicationConfigurationController)); |
|||
options.ControllersToRemove.Add(typeof(AbpApplicationConfigurationScriptController)); |
|||
}); |
|||
|
|||
context.Services.AddAbpSwaggerGenWithOAuth( |
|||
authority: configuration["AuthServer:Authority"], |
|||
scopes: new Dictionary<string, string> |
|||
{ |
|||
{"Account", "Account API"}, |
|||
{"Identity", "Identity API"}, |
|||
{"IdentityServer", "Identity Server API"}, |
|||
{"BackendAdmin", "Backend Admin API"}, |
|||
{"Localization", "Localization API"}, |
|||
{"Platform", "Platform API"}, |
|||
{"RealtimeMessage", "RealtimeMessage API"}, |
|||
{"TaskManagement", "Task Management API"}, |
|||
{"Webhooks", "Webhooks API"}, |
|||
}, |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "ApiGateway", Version = "v1" }); |
|||
options.DocInclusionPredicate((docName, description) => true); |
|||
options.CustomSchemaIds(type => type.FullName); |
|||
}); |
|||
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
|||
.AddJwtBearer(options => |
|||
{ |
|||
configuration.GetSection("AuthServer").Bind(options); |
|||
}); |
|||
|
|||
context.Services |
|||
.AddDataProtection() |
|||
.SetApplicationName("LINGYUN.Abp.Application") |
|||
.PersistKeysToStackExchangeRedis(() => |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); |
|||
|
|||
return redis.GetDatabase(); |
|||
}, |
|||
"LINGYUN.Abp.Application:DataProtection:Protection-Keys"); |
|||
|
|||
context.Services.AddCors(options => |
|||
{ |
|||
options.AddDefaultPolicy(builder => |
|||
{ |
|||
var corsOrigins = configuration.GetSection("App:CorsOrigins").Get<List<string>>(); |
|||
if (corsOrigins == null || corsOrigins.Count == 0) |
|||
{ |
|||
corsOrigins = configuration["App:CorsOrigins"]? |
|||
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToList() ?? new List<string>(); |
|||
} |
|||
|
|||
builder |
|||
.WithOrigins(corsOrigins |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToArray() |
|||
) |
|||
.WithAbpExposedHeaders() |
|||
.WithAbpWrapExposedHeaders() |
|||
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|||
.AllowAnyHeader() |
|||
.AllowAnyMethod() |
|||
.AllowCredentials(); |
|||
}); |
|||
}); |
|||
context.Services.AddWebSockets(options => |
|||
{ |
|||
|
|||
}); |
|||
context.Services.AddHttpForwarder(); |
|||
context.Services.AddTelemetryListeners(); |
|||
|
|||
context.Services |
|||
.AddReverseProxy() |
|||
.ConfigureHttpClient((context, handler) => |
|||
{ |
|||
handler.ActivityHeadersPropagator = null; |
|||
}) |
|||
.LoadFromConfig(configuration.GetSection("ReverseProxy")); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.ApiGateway.Controllers; |
|||
|
|||
public class HomeController : AbpControllerBase |
|||
{ |
|||
public IActionResult Index() |
|||
{ |
|||
return Redirect("/swagger/index.html"); |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.ApiGateway</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> |
|||
<PackageReference Include="Yarp.ReverseProxy" /> |
|||
<PackageReference Include="Yarp.Telemetry.Consumption" /> |
|||
<PackageReference Include="AgileConfig.Client" /> |
|||
<PackageReference Include="Serilog.AspNetCore" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.Localization.CultureMap\LINGYUN.Abp.Localization.CultureMap.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.Application\LINGYUN.Abp.Serilog.Enrichers.Application.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" /> |
|||
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ServiceDefaults\LINGYUN.Abp.MicroService.ServiceDefaults.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="Dockerfile"> |
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,139 @@ |
|||
using LINGYUN.Abp.MicroService.ApiGateway; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using Volo.Abp; |
|||
using Volo.Abp.IO; |
|||
using Volo.Abp.Modularity.PlugIns; |
|||
using Yarp.ReverseProxy.Configuration; |
|||
|
|||
Log.Information("Starting ApiGateway Host..."); |
|||
|
|||
try |
|||
{ |
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.ConfigureAppConfiguration((context, config) => |
|||
{ |
|||
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) |
|||
{ |
|||
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); |
|||
} |
|||
config.AddJsonFile("yarp.json", optional: true, reloadOnChange: true); |
|||
}) |
|||
.UseSerilog((context, provider, config) => |
|||
{ |
|||
config.ReadFrom.Configuration(context.Configuration); |
|||
}); |
|||
|
|||
builder.AddServiceDefaults(); |
|||
|
|||
await builder.AddApplicationAsync<ApiGatewayModule>(options => |
|||
{ |
|||
var applicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME") ?? "ApiGateway"; |
|||
options.ApplicationName = applicationName; |
|||
AbpSerilogEnrichersConsts.ApplicationName = applicationName; |
|||
|
|||
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules"); |
|||
DirectoryHelper.CreateIfNotExists(pluginFolder); |
|||
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories); |
|||
}); |
|||
|
|||
var app = builder.Build(); |
|||
|
|||
await app.InitializeApplicationAsync(); |
|||
|
|||
app.MapDefaultEndpoints(); |
|||
|
|||
if (app.Environment.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
} |
|||
app.UseCorrelationId(); |
|||
app.UseCors(); |
|||
|
|||
// 认证
|
|||
app.UseAuthentication(); |
|||
// jwt
|
|||
app.UseDynamicClaims(); |
|||
// 授权
|
|||
app.UseAuthorization(); |
|||
|
|||
app.UseSwagger(); |
|||
app.UseSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Open API Document"); |
|||
|
|||
var configuration = app.Services.GetRequiredService<IConfiguration>(); |
|||
var logger = app.Services.GetRequiredService<ILogger<ApplicationInitializationContext>>(); |
|||
var proxyConfigProvider = app.Services.GetRequiredService<IProxyConfigProvider>(); |
|||
var yarpConfig = proxyConfigProvider.GetConfig(); |
|||
|
|||
var routedClusters = yarpConfig.Clusters |
|||
.SelectMany(t => t.Destinations, |
|||
(clusterId, destination) => new { clusterId.ClusterId, destination.Value }); |
|||
|
|||
var groupedClusters = routedClusters |
|||
.GroupBy(q => q.Value.Address) |
|||
.Select(t => t.First()) |
|||
.Distinct() |
|||
.ToList(); |
|||
|
|||
foreach (var clusterGroup in groupedClusters) |
|||
{ |
|||
var routeConfig = yarpConfig.Routes.FirstOrDefault(q => |
|||
q.ClusterId == clusterGroup.ClusterId); |
|||
if (routeConfig == null) |
|||
{ |
|||
logger.LogWarning($"Swagger UI: Couldn't find route configuration for {clusterGroup.ClusterId}..."); |
|||
continue; |
|||
} |
|||
|
|||
if (clusterGroup.Value.Metadata != null && |
|||
clusterGroup.Value.Metadata.TryGetValue("SwaggerEndpoint", out var address) && |
|||
!address.IsNullOrWhiteSpace()) |
|||
{ |
|||
options.SwaggerEndpoint($"{address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API"); |
|||
} |
|||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); |
|||
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); |
|||
} |
|||
}); |
|||
|
|||
// app.UseRewriter(new RewriteOptions().AddRedirect("^(|\\|\\s+)$", "/swagger"));
|
|||
|
|||
app.UseRouting(); |
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
app.UseWebSockets(); |
|||
app.UseWebSocketsTelemetry(); |
|||
app.UseConfiguredEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapReverseProxy(); |
|||
}); |
|||
|
|||
await app.RunAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
if (ex is HostAbortedException) |
|||
{ |
|||
throw; |
|||
} |
|||
|
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
{ |
|||
"profiles": { |
|||
"LINGYUN.Abp.MicroService.ApiGateway": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "https://localhost:60437;http://localhost:60438" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
{ |
|||
"App": { |
|||
"CorsOrigins": [ |
|||
"http://localhost:5666", |
|||
"http://localhost:44385", |
|||
"http://localhost:30010", |
|||
"http://localhost:30015", |
|||
"http://localhost:30020", |
|||
"http://localhost:30025", |
|||
"http://localhost:30030", |
|||
"http://localhost:30045", |
|||
"http://localhost:30050", |
|||
"http://localhost:30060" |
|||
], |
|||
"ShowPii": true |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://localhost:44385/", |
|||
"Audience": "lingyun-abp-application", |
|||
"MapInboundClaims": false, |
|||
"RequireHttpsMetadata": false |
|||
}, |
|||
"Logging": { |
|||
"Serilog": { |
|||
"Elasticsearch": { |
|||
"IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" |
|||
} |
|||
} |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://localhost:9200" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"System": "Debug", |
|||
"Microsoft": "Debug", |
|||
"DotNetCore": "Warning", |
|||
"Yarp.ReverseProxy": "Debug" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"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://localhost:9200", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
{ |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"System": "Information", |
|||
"Microsoft": "Information", |
|||
"DotNetCore": "Information", |
|||
"Yarp.ReverseProxy": "Debug" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,538 @@ |
|||
{ |
|||
"ReverseProxy": { |
|||
"Routes": { |
|||
"abp-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/abp/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
}, |
|||
{ |
|||
"ResponseHeadersCopy": true |
|||
}, |
|||
{ |
|||
"ResponseHeader": "Set-Cookie", |
|||
"Append": true |
|||
} |
|||
] |
|||
}, |
|||
"auth-wellknown-route": { |
|||
"ClusterId": "auth-server-cluster", |
|||
"Match": { |
|||
"Path": "/.well-known/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"auth-server-route": { |
|||
"ClusterId": "auth-server-cluster", |
|||
"Match": { |
|||
"Path": "/connect/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"external-logins-route": { |
|||
"ClusterId": "auth-server-cluster", |
|||
"Match": { |
|||
"Path": "/api/account/external-logins/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"oauth-route": { |
|||
"ClusterId": "auth-server-cluster", |
|||
"Match": { |
|||
"Path": "/api/account/oauth/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"qrcode-route": { |
|||
"ClusterId": "auth-server-cluster", |
|||
"Match": { |
|||
"Path": "/api/account/qrcode/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"account-route": { |
|||
"ClusterId": "auth-server-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/account/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"identity-route": { |
|||
"ClusterId": "auth-server-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/identity/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"identity-server-route": { |
|||
"ClusterId": "auth-server-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/identity-server/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"openiddict-route": { |
|||
"ClusterId": "auth-server-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/openiddict/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"cache-management-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/caching-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"saas-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/saas/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"auditing-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/auditing/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"data-protected-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/data-protection-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"text-template-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/text-templating/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"feature-management-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/feature-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"permission-management-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/permission-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"setting-management-route": { |
|||
"ClusterId": "admin-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/setting-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"localization-management-route": { |
|||
"ClusterId": "localization-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/localization/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"im-route": { |
|||
"ClusterId": "messages-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/im/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"notifications-route": { |
|||
"ClusterId": "messages-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/notifications/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"signalr-route": { |
|||
"ClusterId": "messages-api-cluster", |
|||
"Match": { |
|||
"Path": "/signalr-hubs/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
}, |
|||
{ |
|||
"RequestHeadersCopy": true |
|||
}, |
|||
{ |
|||
"ResponseHeadersCopy": true |
|||
} |
|||
] |
|||
}, |
|||
"webhooks-management-route": { |
|||
"ClusterId": "webhooks-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/webhooks/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"task-management-route": { |
|||
"ClusterId": "tasks-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/task-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"platform-route": { |
|||
"ClusterId": "platform-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/platform/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"oss-route": { |
|||
"ClusterId": "platform-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/oss-management/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"files-route": { |
|||
"ClusterId": "platform-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/files/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
}, |
|||
"wechat-route": { |
|||
"ClusterId": "wechat-api-cluster", |
|||
"Match": { |
|||
"Path": "/api/wechat/{**everything}" |
|||
}, |
|||
"Transforms": [ |
|||
{ |
|||
"HeaderPrefix": "X-Forwarded-", |
|||
"X-Forwarded": "Append" |
|||
}, |
|||
{ |
|||
"ResponseHeadersAllowed": "_AbpWrapResult;_AbpDontWrapResult;_AbpErrorFormat" |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
"Clusters": { |
|||
"auth-server-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:44385" |
|||
} |
|||
} |
|||
}, |
|||
"auth-server-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30015", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30015" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"admin-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30010", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30010" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"localization-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30030", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30030" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"messages-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30020", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30020" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"webhooks-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30045", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30045" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"tasks-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30040", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30040" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"platform-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30025", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30025" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"workflow-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30050", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30050" |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"wechat-api-cluster": { |
|||
"Destinations": { |
|||
"destination1": { |
|||
"Address": "http://localhost:30060", |
|||
"Metadata": { |
|||
"SwaggerEndpoint": "http://localhost:30060" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,237 @@ |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
var builder = DistributedApplication.CreateBuilder(args); |
|||
|
|||
// Redis
|
|||
var redis = builder.AddRedis("redis") |
|||
.WithContainerName("redis") |
|||
.WithDataVolume("redis-dev"); |
|||
|
|||
// Elasticsearch
|
|||
var elasticsearch = builder.AddElasticsearch("elasticsearch") |
|||
.WithContainerName("elasticsearch") |
|||
.WithDataVolume("elasticsearch-dev") |
|||
.WithEnvironment("ES_JAVA_OPTS", "-Xms2g -Xmx2g"); |
|||
|
|||
// Postgres
|
|||
var postgres = builder.AddPostgres("postgres") |
|||
.WithPassword(builder.AddParameter("postgres-pwd", "123456", secret: true)) |
|||
.WithImage("postgres", "17-alpine") |
|||
.WithContainerName("postgres") |
|||
.WithDataVolume("postgres-dev"); |
|||
|
|||
var abpDb = postgres.AddDatabase("abp"); |
|||
|
|||
// RabbitMQ
|
|||
var rabbitmq = builder.AddRabbitMQ("rabbitmq", |
|||
userName: builder.AddParameter("rabbitmq-username", "admin", secret: true), |
|||
password: builder.AddParameter("rabbitmq-password", "123456", secret: true)) |
|||
.WithContainerName("rabbitmq") |
|||
.WithDataVolume("rabbitmq-dev") |
|||
.WithManagementPlugin(); |
|||
|
|||
IResourceBuilder<ProjectResource> AddDotNetProject<TDbMigrator, TProject>( |
|||
IDistributedApplicationBuilder builder, |
|||
string servicePrefix, |
|||
int port, |
|||
string portName, |
|||
string serviceSuffix = "Service", |
|||
string migratorSuffix = "Migrator", |
|||
IResourceBuilder<ProjectResource>? waitProject = null) |
|||
where TDbMigrator : IProjectMetadata, new() |
|||
where TProject : IProjectMetadata, new() |
|||
{ |
|||
IResourceBuilder<ProjectResource> service; |
|||
if (builder.Environment.IsDevelopment()) |
|||
{ |
|||
var dbMigrator = builder |
|||
.AddProject<TDbMigrator>($"{servicePrefix}{migratorSuffix}") |
|||
.WithReference(abpDb, "Default") |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis) |
|||
.WaitFor(abpDb) |
|||
.WithReplicas(1); |
|||
|
|||
service = builder.AddProject<TProject>($"{servicePrefix}{serviceSuffix}") |
|||
.WithHttpEndpoint(port: port, name: portName) |
|||
.WithExternalHttpEndpoints() |
|||
.WithReference(abpDb, "Default") |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(rabbitmq, "Rabbitmq") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis) |
|||
.WaitFor(rabbitmq) |
|||
.WaitFor(abpDb) |
|||
.WaitForCompletion(dbMigrator); |
|||
} |
|||
else |
|||
{ |
|||
service = builder.AddProject<TProject>($"{servicePrefix}{serviceSuffix}") |
|||
.WithHttpEndpoint(port: port, name: portName) |
|||
.WithExternalHttpEndpoints() |
|||
.WithReference(abpDb, "Default") |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(rabbitmq, "Rabbitmq") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis) |
|||
.WaitFor(rabbitmq) |
|||
.WaitFor(abpDb) |
|||
.WithExplicitStart(); |
|||
} |
|||
|
|||
if (waitProject != null) |
|||
{ |
|||
service.WaitFor(waitProject, WaitBehavior.WaitOnResourceUnavailable); |
|||
} |
|||
|
|||
return service; |
|||
} |
|||
|
|||
// LocalizationService
|
|||
var localizationService = AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_LocalizationService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_LocalizationService>( |
|||
builder: builder, |
|||
servicePrefix: "Localization", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30030, |
|||
portName: "localization") |
|||
.WithHttpHealthCheck("/service-health"); |
|||
|
|||
// AuthServer
|
|||
var authServer = AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_AuthServer_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_AuthServer>( |
|||
builder: builder, |
|||
servicePrefix: "Auth", |
|||
serviceSuffix: "Server", |
|||
migratorSuffix: "Migrator", |
|||
port: 44385, |
|||
portName: "auth", |
|||
waitProject: localizationService); |
|||
|
|||
// AdminService
|
|||
var adminService = AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_AdminService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_AdminService>( |
|||
builder: builder, |
|||
servicePrefix: "Admin", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30010, |
|||
portName: "admin", |
|||
waitProject: authServer); |
|||
|
|||
// IdentityService
|
|||
AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_AuthServer_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_IdentityService>( |
|||
builder: builder, |
|||
servicePrefix: "Identity", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30015, |
|||
portName: "identity", |
|||
waitProject: authServer); |
|||
|
|||
// TaskService
|
|||
var taskService = AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_TaskService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_TaskService>( |
|||
builder: builder, |
|||
servicePrefix: "Task", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30040, |
|||
portName: "task", |
|||
waitProject: adminService) |
|||
.WithHttpHealthCheck("/service-health"); |
|||
|
|||
// MessageService
|
|||
AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_MessageService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_MessageService>( |
|||
builder: builder, |
|||
servicePrefix: "Message", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30020, |
|||
portName: "message", |
|||
waitProject: taskService); |
|||
|
|||
// WebhookService
|
|||
AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_WebhookService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_WebhookService>( |
|||
builder: builder, |
|||
servicePrefix: "Webhook", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30045, |
|||
portName: "webhook", |
|||
waitProject: taskService); |
|||
|
|||
// PlatformService
|
|||
AddDotNetProject< |
|||
Projects.LINGYUN_Abp_MicroService_PlatformService_DbMigrator, |
|||
Projects.LINGYUN_Abp_MicroService_PlatformService>( |
|||
builder: builder, |
|||
servicePrefix: "Platform", |
|||
serviceSuffix: "Service", |
|||
migratorSuffix: "Migrator", |
|||
port: 30025, |
|||
portName: "platform", |
|||
waitProject: adminService); |
|||
|
|||
// WeChatService
|
|||
builder.AddProject<Projects.LINGYUN_Abp_MicroService_WeChatService>("WeChatService") |
|||
.WithHttpEndpoint(port: 30060, name: "wechat") |
|||
.WithExternalHttpEndpoints() |
|||
.WithReference(abpDb, "Default") |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(rabbitmq, "Rabbitmq") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis) |
|||
.WaitFor(abpDb) |
|||
.WaitFor(rabbitmq); |
|||
|
|||
// WorkflowService
|
|||
builder.AddProject<Projects.LINGYUN_Abp_MicroService_WorkflowService>("WorkflowService") |
|||
.WithHttpEndpoint(port: 30050, name: "workflow") |
|||
.WithExternalHttpEndpoints() |
|||
.WithReference(abpDb, "Default") |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(rabbitmq, "Rabbitmq") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis) |
|||
.WaitFor(abpDb) |
|||
.WaitFor(rabbitmq) |
|||
.WaitFor(taskService); |
|||
|
|||
// ApiGateway
|
|||
var apigateway = builder.AddProject<Projects.LINGYUN_Abp_MicroService_ApiGateway>("ApiGateway") |
|||
.WithHttpEndpoint(port: 30000, name: "gateway") |
|||
.WithExternalHttpEndpoints() |
|||
.WithReference(redis, "Redis") |
|||
.WithReference(elasticsearch, "Elasticsearch") |
|||
.WaitFor(elasticsearch) |
|||
.WaitFor(redis); |
|||
|
|||
// vben5
|
|||
builder.AddViteApp("Frontend", "../../../apps/vben5", "dev:app") |
|||
.WithHttpEndpoint(name: "frontend", env: "VITE_PORT") |
|||
.WithExternalHttpEndpoints() |
|||
.WithEnvironment("BROWSER", "none") |
|||
.WithArgs("--port", "5666") |
|||
.WithPnpm() |
|||
.WithReference(apigateway) |
|||
.WaitFor(apigateway); |
|||
|
|||
builder.Build().Run(); |
|||
@ -0,0 +1,40 @@ |
|||
<Project Sdk="Aspire.AppHost.Sdk/13.1.0"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
<UserSecretsId>13c67981-84b2-4284-81fc-61ede65252c3</UserSecretsId> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Aspire.Hosting.Elasticsearch" /> |
|||
<PackageReference Include="Aspire.Hosting.JavaScript" /> |
|||
<PackageReference Include="Aspire.Hosting.PostgreSQL" /> |
|||
<PackageReference Include="Aspire.Hosting.RabbitMQ" /> |
|||
<PackageReference Include="Aspire.Hosting.Redis" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AdminService.DbMigrator\LINGYUN.Abp.MicroService.AdminService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AdminService\LINGYUN.Abp.MicroService.AdminService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AuthServer.DbMigrator\LINGYUN.Abp.MicroService.AuthServer.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AuthServer\LINGYUN.Abp.MicroService.AuthServer.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.IdentityService\LINGYUN.Abp.MicroService.IdentityService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.PlatformService.DbMigrator\LINGYUN.Abp.MicroService.PlatformService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.PlatformService\LINGYUN.Abp.MicroService.PlatformService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.LocalizationService.DbMigrator\LINGYUN.Abp.MicroService.LocalizationService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.LocalizationService\LINGYUN.Abp.MicroService.LocalizationService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.MessageService.DbMigrator\LINGYUN.Abp.MicroService.MessageService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.MessageService\LINGYUN.Abp.MicroService.MessageService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.TaskService.DbMigrator\LINGYUN.Abp.MicroService.TaskService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.TaskService\LINGYUN.Abp.MicroService.TaskService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.WebhookService.DbMigrator\LINGYUN.Abp.MicroService.WebhookService.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.WebhookService\LINGYUN.Abp.MicroService.WebhookService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.WeChatService\LINGYUN.Abp.MicroService.WeChatService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.WorkflowService\LINGYUN.Abp.MicroService.WorkflowService.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ApiGateway\LINGYUN.Abp.MicroService.ApiGateway.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,33 @@ |
|||
{ |
|||
"$schema": "https://json.schemastore.org/launchsettings.json", |
|||
"profiles": { |
|||
"https": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": true, |
|||
"launchBrowser": true, |
|||
"applicationUrl": "https://localhost:17291;http://localhost:15258", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development", |
|||
"DOTNET_ENVIRONMENT": "Development", |
|||
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21219", |
|||
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23177", |
|||
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22076", |
|||
"OTEL_DOTNET_EXPERIMENTAL_EFCORE_ENABLE_TRACE_DB_QUERY_PARAMETERS": "true" |
|||
} |
|||
}, |
|||
"http": { |
|||
"commandName": "Project", |
|||
"dotnetRunMessages": true, |
|||
"launchBrowser": true, |
|||
"applicationUrl": "http://localhost:15258", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development", |
|||
"DOTNET_ENVIRONMENT": "Development", |
|||
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19236", |
|||
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18177", |
|||
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20189", |
|||
"OTEL_DOTNET_EXPERIMENTAL_EFCORE_ENABLE_TRACE_DB_QUERY_PARAMETERS": "true" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.AspNetCore": "Warning" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"Logging": { |
|||
"LogLevel": { |
|||
"Default": "Information", |
|||
"Microsoft.AspNetCore": "Warning", |
|||
"Aspire.Hosting.Dcp": "Warning" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
public class AuthServerDbMigratorHostedService : IHostedService |
|||
{ |
|||
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public AuthServerDbMigratorHostedService( |
|||
IHostApplicationLifetime hostApplicationLifetime, |
|||
IConfiguration configuration) |
|||
{ |
|||
_hostApplicationLifetime = hostApplicationLifetime; |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using var application = await AbpApplicationFactory |
|||
.CreateAsync<AuthServerDbMigratorModule>(options => |
|||
{ |
|||
options.Services.ReplaceConfiguration(_configuration); |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
options.AddDataMigrationEnvironment(); |
|||
}); |
|||
await application.InitializeAsync(); |
|||
|
|||
await application |
|||
.ServiceProvider |
|||
.GetRequiredService<AuthServerDbMigrationService>() |
|||
.CheckAndApplyDatabaseMigrationsAsync(); |
|||
|
|||
await application.ShutdownAsync(); |
|||
|
|||
_hostApplicationLifetime.StopApplication(); |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AuthServerMigrationsEntityFrameworkCoreModule))] |
|||
public class AuthServerDbMigratorModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
<IsPackable>false</IsPackable> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AuthServer</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Extensions.Logging" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" /> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AuthServer.EntityFrameworkCore\LINGYUN.Abp.MicroService.AuthServer.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="appsettings.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,43 @@ |
|||
using LINGYUN.Abp.MicroService.AuthServer; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
var defaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"; |
|||
|
|||
Log.Logger = new LoggerConfiguration() |
|||
.MinimumLevel.Information() |
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|||
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
|||
#if DEBUG
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.AuthServer", LogEventLevel.Debug) |
|||
#else
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.AuthServer", LogEventLevel.Information) |
|||
#endif
|
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(x => x.Console(outputTemplate: defaultOutputTemplate)) |
|||
.WriteTo.Async(x => x.File("Logs/migrations.txt", outputTemplate: defaultOutputTemplate)) |
|||
.CreateLogger(); |
|||
|
|||
try |
|||
{ |
|||
var builder = Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<AuthServerDbMigratorHostedService>(); |
|||
}); |
|||
await builder.RunConsoleAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
} |
|||
} |
|||
@ -0,0 +1,132 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EntityFrameworkCore.Migrations; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using IdentityPermissions = Volo.Abp.Identity.IdentityPermissions; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
public class AuthServerDbMigrationEventHandler : EfCoreDatabaseMigrationEventHandlerBase<AuthServerMigrationsDbContext> |
|||
{ |
|||
protected IGuidGenerator GuidGenerator { get; } |
|||
protected IdentityUserManager IdentityUserManager { get; } |
|||
protected IdentityRoleManager IdentityRoleManager { get; } |
|||
protected IPermissionDataSeeder PermissionDataSeeder { get; } |
|||
|
|||
public AuthServerDbMigrationEventHandler( |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
ITenantStore tenantStore, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory, |
|||
IGuidGenerator guidGenerator, |
|||
IdentityUserManager identityUserManager, |
|||
IdentityRoleManager identityRoleManager, |
|||
IPermissionDataSeeder permissionDataSeeder) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<AuthServerMigrationsDbContext>(), |
|||
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
GuidGenerator = guidGenerator; |
|||
IdentityUserManager = identityUserManager; |
|||
IdentityRoleManager = identityRoleManager; |
|||
PermissionDataSeeder = permissionDataSeeder; |
|||
} |
|||
|
|||
protected async override Task AfterTenantCreated(TenantCreatedEto eventData, bool schemaMigrated) |
|||
{ |
|||
if (!schemaMigrated) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
using (CurrentTenant.Change(eventData.Id)) |
|||
{ |
|||
await SeedTenantDefaultRoleAsync(eventData); |
|||
await SeedTenantAdminAsync(eventData); |
|||
} |
|||
} |
|||
|
|||
protected async virtual Task SeedTenantDefaultRoleAsync(TenantCreatedEto eventData) |
|||
{ |
|||
// 默认用户
|
|||
var roleId = GuidGenerator.Create(); |
|||
var defaultRole = new IdentityRole(roleId, "Users", eventData.Id) |
|||
{ |
|||
IsStatic = true, |
|||
IsPublic = true, |
|||
IsDefault = true, |
|||
}; |
|||
(await IdentityRoleManager.CreateAsync(defaultRole)).CheckErrors(); |
|||
|
|||
// 所有用户都应该具有查询用户权限, 用于IM场景
|
|||
await PermissionDataSeeder.SeedAsync( |
|||
RolePermissionValueProvider.ProviderName, |
|||
defaultRole.Name, |
|||
new string[] |
|||
{ |
|||
IdentityPermissions.UserLookup.Default, |
|||
IdentityPermissions.Users.Default |
|||
}, |
|||
tenantId: eventData.Id); |
|||
} |
|||
|
|||
protected async virtual Task SeedTenantAdminAsync(TenantCreatedEto eventData) |
|||
{ |
|||
const string tenantAdminUserName = "admin"; |
|||
const string tenantAdminRoleName = "admin"; |
|||
Guid tenantAdminRoleId; |
|||
if (!await IdentityRoleManager.RoleExistsAsync(tenantAdminRoleName)) |
|||
{ |
|||
tenantAdminRoleId = GuidGenerator.Create(); |
|||
var tenantAdminRole = new IdentityRole(tenantAdminRoleId, tenantAdminRoleName, eventData.Id) |
|||
{ |
|||
IsStatic = true, |
|||
IsPublic = true |
|||
}; |
|||
(await IdentityRoleManager.CreateAsync(tenantAdminRole)).CheckErrors(); |
|||
} |
|||
else |
|||
{ |
|||
var tenantAdminRole = await IdentityRoleManager.FindByNameAsync(tenantAdminRoleName); |
|||
tenantAdminRoleId = tenantAdminRole.Id; |
|||
} |
|||
|
|||
var adminUserId = GuidGenerator.Create(); |
|||
if (eventData.Properties.TryGetValue("AdminUserId", out var userIdString) && |
|||
Guid.TryParse(userIdString, out var adminUserGuid)) |
|||
{ |
|||
adminUserId = adminUserGuid; |
|||
} |
|||
var adminEmailAddress = eventData.Properties.GetOrDefault("AdminEmail") ?? "admin@abp.io"; |
|||
var adminPassword = eventData.Properties.GetOrDefault("AdminPassword") ?? "1q2w3E*"; |
|||
|
|||
var tenantAdminUser = await IdentityUserManager.FindByNameAsync(adminEmailAddress); |
|||
if (tenantAdminUser == null) |
|||
{ |
|||
tenantAdminUser = new IdentityUser( |
|||
adminUserId, |
|||
tenantAdminUserName, |
|||
adminEmailAddress, |
|||
eventData.Id); |
|||
|
|||
tenantAdminUser.AddRole(tenantAdminRoleId); |
|||
|
|||
// 创建租户管理用户
|
|||
(await IdentityUserManager.CreateAsync(tenantAdminUser)).CheckErrors(); |
|||
(await IdentityUserManager.AddPasswordAsync(tenantAdminUser, adminPassword)).CheckErrors(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.Saas.Tenants; |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
public class AuthServerDbMigrationService : EfCoreRuntimeDbMigratorBase<AuthServerMigrationsDbContext>, ITransientDependency |
|||
{ |
|||
public AuthServerDbMigrationService( |
|||
IDataSeeder dataSeeder, |
|||
IDbSchemaMigrator dbSchemaMigrator, |
|||
ITenantRepository tenantRepository, |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
IServiceProvider serviceProvider, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<AuthServerMigrationsDbContext>(), |
|||
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
using LINGYUN.Abp.Gdpr; |
|||
using LINGYUN.Abp.Gdpr.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Identity.EntityFrameworkCore; |
|||
using Volo.Abp.OpenIddict.Applications; |
|||
using Volo.Abp.OpenIddict.Authorizations; |
|||
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
|||
using Volo.Abp.OpenIddict.Scopes; |
|||
using Volo.Abp.OpenIddict.Tokens; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
[ConnectionStringName("Default")] |
|||
public class AuthServerMigrationsDbContext : |
|||
AbpDbContext<AuthServerMigrationsDbContext>, |
|||
IIdentityDbContext, |
|||
IOpenIddictDbContext, |
|||
IGdprDbContext |
|||
{ |
|||
public DbSet<GdprRequest> Requests { get; set; } |
|||
|
|||
public DbSet<OpenIddictApplication> Applications { get; set; } |
|||
|
|||
public DbSet<OpenIddictAuthorization> Authorizations { get; set; } |
|||
|
|||
public DbSet<OpenIddictScope> Scopes { get; set; } |
|||
|
|||
public DbSet<OpenIddictToken> Tokens { get; set; } |
|||
|
|||
public DbSet<IdentityUser> Users { get; set; } |
|||
|
|||
public DbSet<IdentityRole> Roles { get; set; } |
|||
|
|||
public DbSet<IdentityClaimType> ClaimTypes { get; set; } |
|||
|
|||
public DbSet<OrganizationUnit> OrganizationUnits { get; set; } |
|||
|
|||
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; } |
|||
|
|||
public DbSet<IdentityLinkUser> LinkUsers { get; set; } |
|||
|
|||
public DbSet<IdentityUserDelegation> UserDelegations { get; set; } |
|||
|
|||
public DbSet<IdentitySession> Sessions { get; set; } |
|||
|
|||
public AuthServerMigrationsDbContext(DbContextOptions<AuthServerMigrationsDbContext> options) |
|||
: base(options) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureIdentity(); |
|||
modelBuilder.ConfigureOpenIddict(); |
|||
modelBuilder.ConfigureGdpr(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.IO; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
public class AuthServerMigrationsDbContextFactory : IDesignTimeDbContextFactory<AuthServerMigrationsDbContext> |
|||
{ |
|||
public AuthServerMigrationsDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
var connectionString = configuration.GetConnectionString("Default"); |
|||
|
|||
var builder = new DbContextOptionsBuilder<AuthServerMigrationsDbContext>() |
|||
.UseNpgsql(connectionString); |
|||
|
|||
return new AuthServerMigrationsDbContext(builder!.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../LINGYUN.Abp.MicroService.AuthServer.DbMigrator/")) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.Gdpr.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Identity.EntityFrameworkCore; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
|||
using LINGYUN.Platform.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.PostgreSql; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAuthorizationModule), |
|||
typeof(AbpSaasEntityFrameworkCoreModule), |
|||
typeof(AbpOpenIddictEntityFrameworkCoreModule), |
|||
typeof(AbpIdentityEntityFrameworkCoreModule), |
|||
typeof(AbpGdprEntityFrameworkCoreModule), |
|||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
|||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
|||
typeof(AbpTextTemplatingEntityFrameworkCoreModule), |
|||
typeof(PlatformEntityFrameworkCoreModule), |
|||
typeof(AbpEntityFrameworkCorePostgreSqlModule), |
|||
typeof(AbpDataDbMigratorModule) |
|||
)] |
|||
public class AuthServerMigrationsEntityFrameworkCoreModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAbpDbContext<AuthServerMigrationsDbContext>(); |
|||
|
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.UseNpgsql(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,36 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<IsPackable>false</IsPackable> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AuthServer</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Volo.Abp.Authorization" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" /> |
|||
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.EntityFrameworkCore\LINGYUN.Abp.Gdpr.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Platform.EntityFrameworkCore\LINGYUN.Platform.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
File diff suppressed because it is too large
@ -0,0 +1,739 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class Initial_Auth_Server : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpClaimTypes", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
Required = table.Column<bool>(type: "boolean", nullable: false), |
|||
IsStatic = table.Column<bool>(type: "boolean", nullable: false), |
|||
Regex = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true), |
|||
RegexDescription = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true), |
|||
Description = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
ValueType = table.Column<int>(type: "integer", nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpGdprRequests", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
ReadyTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpGdprRequests", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpLinkUsers", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
SourceUserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
SourceTenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
TargetUserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TargetTenantId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpOrganizationUnits", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
ParentId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Code = table.Column<string>(type: "character varying(95)", maxLength: 95, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
EntityVersion = table.Column<int>(type: "integer", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", |
|||
column: x => x.ParentId, |
|||
principalTable: "AbpOrganizationUnits", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpRoles", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
IsDefault = table.Column<bool>(type: "boolean", nullable: false), |
|||
IsStatic = table.Column<bool>(type: "boolean", nullable: false), |
|||
IsPublic = table.Column<bool>(type: "boolean", nullable: false), |
|||
EntityVersion = table.Column<int>(type: "integer", nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpRoles", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpSecurityLogs", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
ApplicationName = table.Column<string>(type: "character varying(96)", maxLength: 96, nullable: true), |
|||
Identity = table.Column<string>(type: "character varying(96)", maxLength: 96, nullable: true), |
|||
Action = table.Column<string>(type: "character varying(96)", maxLength: 96, nullable: true), |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
TenantName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
ClientId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
CorrelationId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
ClientIpAddress = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
BrowserInfo = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpSessions", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
SessionId = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
Device = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
DeviceInfo = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ClientId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
IpAddresses = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true), |
|||
SignedIn = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
LastAccessed = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpSessions", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserDelegations", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
SourceUserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TargetUserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
StartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
EndTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserDelegations", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUsers", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
Surname = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
PasswordHash = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
|||
SecurityStamp = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
IsExternal = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
PhoneNumber = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true), |
|||
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
IsActive = table.Column<bool>(type: "boolean", nullable: false), |
|||
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
|||
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
AccessFailedCount = table.Column<int>(type: "integer", nullable: false, defaultValue: 0), |
|||
ShouldChangePasswordOnNextLogin = table.Column<bool>(type: "boolean", nullable: false), |
|||
EntityVersion = table.Column<int>(type: "integer", nullable: false), |
|||
LastPasswordChangeTime = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUsers", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictApplications", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ApplicationType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
ClientId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
|||
ClientSecret = table.Column<string>(type: "text", nullable: true), |
|||
ClientType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
ConsentType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
DisplayName = table.Column<string>(type: "text", nullable: true), |
|||
DisplayNames = table.Column<string>(type: "text", nullable: true), |
|||
JsonWebKeySet = table.Column<string>(type: "text", nullable: true), |
|||
Permissions = table.Column<string>(type: "text", nullable: true), |
|||
PostLogoutRedirectUris = table.Column<string>(type: "text", nullable: true), |
|||
Properties = table.Column<string>(type: "text", nullable: true), |
|||
RedirectUris = table.Column<string>(type: "text", nullable: true), |
|||
Requirements = table.Column<string>(type: "text", nullable: true), |
|||
Settings = table.Column<string>(type: "text", nullable: true), |
|||
ClientUri = table.Column<string>(type: "text", nullable: true), |
|||
LogoUri = table.Column<string>(type: "text", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictScopes", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Description = table.Column<string>(type: "text", nullable: true), |
|||
Descriptions = table.Column<string>(type: "text", nullable: true), |
|||
DisplayName = table.Column<string>(type: "text", nullable: true), |
|||
DisplayNames = table.Column<string>(type: "text", nullable: true), |
|||
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true), |
|||
Properties = table.Column<string>(type: "text", nullable: true), |
|||
Resources = table.Column<string>(type: "text", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpGdprInfos", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
RequestId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Data = table.Column<string>(type: "text", nullable: false), |
|||
Provider = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpGdprInfos", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpGdprInfos_AbpGdprRequests_RequestId", |
|||
column: x => x.RequestId, |
|||
principalTable: "AbpGdprRequests", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpOrganizationUnitRoles", |
|||
columns: table => new |
|||
{ |
|||
RoleId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrganizationUnitId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationU~", |
|||
column: x => x.OrganizationUnitId, |
|||
principalTable: "AbpOrganizationUnits", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
table.ForeignKey( |
|||
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", |
|||
column: x => x.RoleId, |
|||
principalTable: "AbpRoles", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpRoleClaims", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
RoleId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
ClaimType = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
ClaimValue = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpRoleClaims_AbpRoles_RoleId", |
|||
column: x => x.RoleId, |
|||
principalTable: "AbpRoles", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserClaims", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
ClaimType = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
|||
ClaimValue = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserClaims", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserClaims_AbpUsers_UserId", |
|||
column: x => x.UserId, |
|||
principalTable: "AbpUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserLogins", |
|||
columns: table => new |
|||
{ |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
LoginProvider = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
ProviderKey = table.Column<string>(type: "character varying(196)", maxLength: 196, nullable: false), |
|||
ProviderDisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserLogins_AbpUsers_UserId", |
|||
column: x => x.UserId, |
|||
principalTable: "AbpUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserOrganizationUnits", |
|||
columns: table => new |
|||
{ |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrganizationUnitId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationU~", |
|||
column: x => x.OrganizationUnitId, |
|||
principalTable: "AbpOrganizationUnits", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", |
|||
column: x => x.UserId, |
|||
principalTable: "AbpUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserRoles", |
|||
columns: table => new |
|||
{ |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
RoleId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserRoles_AbpRoles_RoleId", |
|||
column: x => x.RoleId, |
|||
principalTable: "AbpRoles", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserRoles_AbpUsers_UserId", |
|||
column: x => x.UserId, |
|||
principalTable: "AbpUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpUserTokens", |
|||
columns: table => new |
|||
{ |
|||
UserId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
LoginProvider = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
Name = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
|||
TenantId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Value = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); |
|||
table.ForeignKey( |
|||
name: "FK_AbpUserTokens_AbpUsers_UserId", |
|||
column: x => x.UserId, |
|||
principalTable: "AbpUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictAuthorizations", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ApplicationId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
Properties = table.Column<string>(type: "text", nullable: true), |
|||
Scopes = table.Column<string>(type: "text", nullable: true), |
|||
Status = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
Subject = table.Column<string>(type: "character varying(400)", maxLength: 400, nullable: true), |
|||
Type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictAuthorizations_OpenIddictApplications_Application~", |
|||
column: x => x.ApplicationId, |
|||
principalTable: "OpenIddictApplications", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OpenIddictTokens", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ApplicationId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
AuthorizationId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
ExpirationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
Payload = table.Column<string>(type: "text", nullable: true), |
|||
Properties = table.Column<string>(type: "text", nullable: true), |
|||
RedemptionDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
ReferenceId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
|||
Status = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
Subject = table.Column<string>(type: "character varying(400)", maxLength: 400, nullable: true), |
|||
Type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", |
|||
column: x => x.ApplicationId, |
|||
principalTable: "OpenIddictApplications", |
|||
principalColumn: "Id"); |
|||
table.ForeignKey( |
|||
name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", |
|||
column: x => x.AuthorizationId, |
|||
principalTable: "OpenIddictAuthorizations", |
|||
principalColumn: "Id"); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpGdprInfos_RequestId", |
|||
table: "AbpGdprInfos", |
|||
column: "RequestId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpGdprRequests_UserId", |
|||
table: "AbpGdprRequests", |
|||
column: "UserId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_Targe~", |
|||
table: "AbpLinkUsers", |
|||
columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, |
|||
unique: true); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", |
|||
table: "AbpOrganizationUnitRoles", |
|||
columns: new[] { "RoleId", "OrganizationUnitId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpOrganizationUnits_Code", |
|||
table: "AbpOrganizationUnits", |
|||
column: "Code"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpOrganizationUnits_ParentId", |
|||
table: "AbpOrganizationUnits", |
|||
column: "ParentId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpRoleClaims_RoleId", |
|||
table: "AbpRoleClaims", |
|||
column: "RoleId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpRoles_NormalizedName", |
|||
table: "AbpRoles", |
|||
column: "NormalizedName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSecurityLogs_TenantId_Action", |
|||
table: "AbpSecurityLogs", |
|||
columns: new[] { "TenantId", "Action" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSecurityLogs_TenantId_ApplicationName", |
|||
table: "AbpSecurityLogs", |
|||
columns: new[] { "TenantId", "ApplicationName" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSecurityLogs_TenantId_Identity", |
|||
table: "AbpSecurityLogs", |
|||
columns: new[] { "TenantId", "Identity" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSecurityLogs_TenantId_UserId", |
|||
table: "AbpSecurityLogs", |
|||
columns: new[] { "TenantId", "UserId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSessions_Device", |
|||
table: "AbpSessions", |
|||
column: "Device"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSessions_SessionId", |
|||
table: "AbpSessions", |
|||
column: "SessionId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpSessions_TenantId_UserId", |
|||
table: "AbpSessions", |
|||
columns: new[] { "TenantId", "UserId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUserClaims_UserId", |
|||
table: "AbpUserClaims", |
|||
column: "UserId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUserLogins_LoginProvider_ProviderKey", |
|||
table: "AbpUserLogins", |
|||
columns: new[] { "LoginProvider", "ProviderKey" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", |
|||
table: "AbpUserOrganizationUnits", |
|||
columns: new[] { "UserId", "OrganizationUnitId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUserRoles_RoleId_UserId", |
|||
table: "AbpUserRoles", |
|||
columns: new[] { "RoleId", "UserId" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUsers_Email", |
|||
table: "AbpUsers", |
|||
column: "Email"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUsers_NormalizedEmail", |
|||
table: "AbpUsers", |
|||
column: "NormalizedEmail"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUsers_NormalizedUserName", |
|||
table: "AbpUsers", |
|||
column: "NormalizedUserName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpUsers_UserName", |
|||
table: "AbpUsers", |
|||
column: "UserName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictApplications_ClientId", |
|||
table: "OpenIddictApplications", |
|||
column: "ClientId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", |
|||
table: "OpenIddictAuthorizations", |
|||
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictScopes_Name", |
|||
table: "OpenIddictScopes", |
|||
column: "Name"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", |
|||
table: "OpenIddictTokens", |
|||
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_AuthorizationId", |
|||
table: "OpenIddictTokens", |
|||
column: "AuthorizationId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OpenIddictTokens_ReferenceId", |
|||
table: "OpenIddictTokens", |
|||
column: "ReferenceId"); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpClaimTypes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpGdprInfos"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpLinkUsers"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpOrganizationUnitRoles"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpRoleClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpSecurityLogs"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpSessions"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserClaims"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserDelegations"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserLogins"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserOrganizationUnits"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserRoles"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUserTokens"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictScopes"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictTokens"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpGdprRequests"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpOrganizationUnits"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpRoles"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpUsers"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictAuthorizations"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OpenIddictApplications"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,475 @@ |
|||
using DotNetCore.CAP; |
|||
using LINGYUN.Abp.AspNetCore.MultiTenancy; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.LocalizationManagement; |
|||
using LINGYUN.Abp.MicroService.AuthServer.Ui.Branding; |
|||
using LINGYUN.Abp.OpenIddict.AspNetCore.Session; |
|||
using LINGYUN.Abp.OpenIddict.LinkUser; |
|||
using LINGYUN.Abp.OpenIddict.Portal; |
|||
using LINGYUN.Abp.OpenIddict.Sms; |
|||
using LINGYUN.Abp.OpenIddict.WeChat; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.WeChat.Work; |
|||
using LINGYUN.Abp.Wrapper; |
|||
using Medallion.Threading; |
|||
using Medallion.Threading.Redis; |
|||
using Microsoft.AspNetCore.Authentication.Cookies; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Cors; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.AspNetCore.Extensions.DependencyInjection; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.AspNetCore.Routing; |
|||
using Microsoft.Extensions.Caching.StackExchangeRedis; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.IdentityModel.Logging; |
|||
using Microsoft.IdentityModel.Tokens; |
|||
using OpenIddict.Server; |
|||
using OpenIddict.Server.AspNetCore; |
|||
using OpenIddict.Validation.AspNetCore; |
|||
using StackExchange.Redis; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Encodings.Web; |
|||
using System.Text.Unicode; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Auditing; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.Abp.Http.Client; |
|||
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.WildcardDomains; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Security.Claims; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.Timing; |
|||
using Volo.Abp.UI.Navigation.Urls; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
public partial class AuthServerModule |
|||
{ |
|||
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
|||
|
|||
private void PreConfigureFeature() |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); |
|||
}); |
|||
} |
|||
|
|||
private void PreForwardedHeaders() |
|||
{ |
|||
} |
|||
|
|||
private void PreConfigureApp(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options => |
|||
{ |
|||
// 以开放端口区别,应在0-31之间
|
|||
options.SnowflakeIdOptions.WorkerId = 1; |
|||
options.SnowflakeIdOptions.WorkerIdBits = 5; |
|||
options.SnowflakeIdOptions.DatacenterId = 1; |
|||
}); |
|||
|
|||
if (configuration.GetValue<bool>("App:ShowPii")) |
|||
{ |
|||
IdentityModelEventSource.ShowPII = true; |
|||
} |
|||
} |
|||
|
|||
private void PreConfigureCAP(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<CapOptions>(options => |
|||
{ |
|||
options |
|||
.UsePostgreSql(mySqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:PostgreSql").Bind(mySqlOptions); |
|||
}) |
|||
.UseRabbitMQ(rabbitMQOptions => |
|||
{ |
|||
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
|||
}) |
|||
.UseDashboard(); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureAuthServer() |
|||
{ |
|||
PreConfigure<OpenIddictBuilder>(builder => |
|||
{ |
|||
builder.AddValidation(options => |
|||
{ |
|||
//options.AddAudiences("lingyun-abp-application");
|
|||
|
|||
options.UseLocalServer(); |
|||
|
|||
options.UseAspNetCore(); |
|||
|
|||
options.UseDataProtection(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureCertificate(IConfiguration configuration, IWebHostEnvironment environment) |
|||
{ |
|||
if (!environment.IsDevelopment()) |
|||
{ |
|||
PreConfigure<AbpOpenIddictAspNetCoreOptions>(options => |
|||
{ |
|||
options.AddDevelopmentEncryptionAndSigningCertificate = false; |
|||
}); |
|||
|
|||
PreConfigure<OpenIddictServerBuilder>(builder => |
|||
{ |
|||
builder.AddProductionEncryptionAndSigningCertificate(configuration["App:SslFile"], configuration["App:SslPassword"]); |
|||
}); |
|||
} |
|||
|
|||
PreConfigure<OpenIddictServerBuilder>(builder => |
|||
{ |
|||
// builder.UseDataProtection();
|
|||
|
|||
// 禁用https
|
|||
builder.UseAspNetCore() |
|||
.DisableTransportSecurityRequirement(); |
|||
}); |
|||
|
|||
var wildcardDomains = configuration.GetSection("App:WildcardDomains").Get<List<string>>(); |
|||
if (wildcardDomains?.Count > 0) |
|||
{ |
|||
PreConfigure<AbpOpenIddictWildcardDomainOptions>(options => |
|||
{ |
|||
options.EnableWildcardDomainSupport = true; |
|||
options.WildcardDomainsFormat.AddIfNotContains(wildcardDomains); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureMvc(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAspNetCoreMvcOptions>(options => |
|||
{ |
|||
options.ExposeIntegrationServices = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDataSeeder() |
|||
{ |
|||
|
|||
} |
|||
|
|||
private void ConfigureFeatureManagement() |
|||
{ |
|||
Configure<FeatureManagementOptions>(options => |
|||
{ |
|||
options.IsDynamicFeatureStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigurePermissionManagement() |
|||
{ |
|||
Configure<PermissionManagementOptions>(options => |
|||
{ |
|||
options.SaveStaticPermissionsToDatabase = false; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSettingManagement() |
|||
{ |
|||
Configure<SettingManagementOptions>(options => |
|||
{ |
|||
options.IsDynamicSettingStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureJsonSerializer(IConfiguration configuration) |
|||
{ |
|||
// 统一时间日期格式
|
|||
Configure<AbpJsonOptions>(options => |
|||
{ |
|||
var jsonConfiguration = configuration.GetSection("Json"); |
|||
if (jsonConfiguration.Exists()) |
|||
{ |
|||
jsonConfiguration.Bind(options); |
|||
} |
|||
}); |
|||
// 中文序列化的编码问题
|
|||
Configure<AbpSystemTextJsonSerializerOptions>(options => |
|||
{ |
|||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDistributedLocking(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
var distributedLockEnabled = configuration["DistributedLock:IsEnabled"]; |
|||
if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) |
|||
{ |
|||
services.AddSingleton<IDistributedLockProvider>(sp => |
|||
{ |
|||
var connectionMultiplexer = sp.GetRequiredService<IConnectionMultiplexer>(); |
|||
return new RedisDistributedSynchronizationProvider(connectionMultiplexer.GetDatabase()); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureBranding(IConfiguration configuration) |
|||
{ |
|||
Configure<AccountBrandingOptions>(options => |
|||
{ |
|||
configuration.GetSection("App:Branding").Bind(options); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCaching(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpDistributedCacheOptions>(options => |
|||
{ |
|||
configuration.GetSection("DistributedCache").Bind(options); |
|||
}); |
|||
|
|||
Configure<RedisCacheOptions>(options => |
|||
{ |
|||
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
|||
options.ConfigurationOptions = redisConfig; |
|||
options.InstanceName = configuration["Redis:InstanceName"]; |
|||
}); |
|||
} |
|||
private void ConfigureIdentity(IConfiguration configuration) |
|||
{ |
|||
// 增加配置文件定义,在新建租户时需要
|
|||
Configure<IdentityOptions>(options => |
|||
{ |
|||
var identityConfiguration = configuration.GetSection("Identity"); |
|||
if (identityConfiguration.Exists()) |
|||
{ |
|||
identityConfiguration.Bind(options); |
|||
} |
|||
}); |
|||
Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
options.IsDynamicClaimsEnabled = true; |
|||
options.IsRemoteRefreshEnabled = false; |
|||
}); |
|||
|
|||
Configure<AbpOpenIddictAspNetCoreSessionOptions>(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 ConfigureVirtualFileSystem() |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AuthServerModule>("LINGYUN.Abp.MicroService.AuthServer"); |
|||
}); |
|||
} |
|||
private void ConfigureLocalization() |
|||
{ |
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationCultureMapOptions>(options => |
|||
{ |
|||
var zhHansCultureMapInfo = new CultureMapInfo |
|||
{ |
|||
TargetCulture = "zh-Hans", |
|||
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
|||
}; |
|||
|
|||
options.CulturesMaps.Add(zhHansCultureMapInfo); |
|||
options.UiCulturesMaps.Add(zhHansCultureMapInfo); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationManagementOptions>(options => |
|||
{ |
|||
options.SaveStaticLocalizationsToDatabase = true; |
|||
}); |
|||
} |
|||
private void ConfigureTiming(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpClockOptions>(options => |
|||
{ |
|||
configuration.GetSection("Clock").Bind(options); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAuditing(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
// options.IsEnabledForGetRequests = true;
|
|||
// 是否启用实体变更记录
|
|||
var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; |
|||
if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || |
|||
(bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) |
|||
{ |
|||
options.EntityHistorySelectors.AddAllEntities(); |
|||
} |
|||
}); |
|||
} |
|||
private void ConfigureUrls(IConfiguration configuration) |
|||
{ |
|||
Configure<AppUrlOptions>(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 ConfigureAuthServer(IConfiguration configuration) |
|||
{ |
|||
Configure<OpenIddictServerAspNetCoreBuilder>(builder => |
|||
{ |
|||
builder.DisableTransportSecurityRequirement(); |
|||
}); |
|||
|
|||
Configure<OpenIddictServerAspNetCoreOptions>(options => |
|||
{ |
|||
options.DisableTransportSecurityRequirement = true; |
|||
}); |
|||
|
|||
Configure<OpenIddictServerOptions>(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); |
|||
}); |
|||
} |
|||
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
|||
{ |
|||
services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); |
|||
|
|||
services |
|||
.AddAuthentication() |
|||
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => |
|||
{ |
|||
options.ExpireTimeSpan = TimeSpan.FromDays(365); |
|||
}) |
|||
.AddJwtBearer(options => |
|||
{ |
|||
configuration.GetSection("AuthServer").Bind(options); |
|||
|
|||
var validIssuers = configuration.GetSection("AuthServer:ValidIssuers").Get<List<string>>(); |
|||
if (validIssuers?.Count > 0) |
|||
{ |
|||
options.TokenValidationParameters.ValidIssuers = validIssuers; |
|||
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator; |
|||
} |
|||
}); |
|||
//.AddWeChatWork(options =>
|
|||
//{
|
|||
// options.SignInScheme = IdentityConstants.ExternalScheme;
|
|||
//});
|
|||
|
|||
services |
|||
.AddDataProtection() |
|||
.SetApplicationName("LINGYUN.Abp.Application") |
|||
.PersistKeysToStackExchangeRedis(() => |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); |
|||
|
|||
return redis.GetDatabase(); |
|||
}, |
|||
"LINGYUN.Abp.Application:DataProtection:Protection-Keys"); |
|||
|
|||
services.AddSameSiteCookiePolicy(); |
|||
} |
|||
private void ConfigureMultiTenancy(IConfiguration configuration) |
|||
{ |
|||
// 多租户
|
|||
Configure<AbpMultiTenancyOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
|
|||
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
|||
if (tenantResolveCfg.Exists()) |
|||
{ |
|||
Configure<AbpTenantResolveOptions>(options => |
|||
{ |
|||
var domains = tenantResolveCfg.Get<string[]>(); |
|||
foreach (var domain in domains) |
|||
{ |
|||
options.AddOnlyDomainTenantResolver(domain); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
private void ConfigureCors(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
services.AddCors(options => |
|||
{ |
|||
options.AddDefaultPolicy(builder => |
|||
{ |
|||
var corsOrigins = configuration.GetSection("App:CorsOrigins").Get<List<string>>(); |
|||
if (corsOrigins == null || corsOrigins.Count == 0) |
|||
{ |
|||
corsOrigins = configuration["App:CorsOrigins"]? |
|||
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToList() ?? new List<string>(); |
|||
} |
|||
builder |
|||
.WithOrigins(corsOrigins |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToArray() |
|||
) |
|||
.WithAbpExposedHeaders() |
|||
.WithAbpWrapExposedHeaders() |
|||
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|||
.AllowAnyHeader() |
|||
.AllowAnyMethod() |
|||
.AllowCredentials(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureWrapper() |
|||
{ |
|||
PreConfigure<AbpHttpClientBuilderOptions>(options => |
|||
{ |
|||
// http服务间调用发送不需要包装结果的请求头
|
|||
options.ProxyClientActions.Add( |
|||
(_, _, client) => |
|||
{ |
|||
client.DefaultRequestHeaders.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
using LINGYUN.Abp.Account; |
|||
using LINGYUN.Abp.Account.Web.OAuth; |
|||
using LINGYUN.Abp.Account.Web.OpenIddict; |
|||
using LINGYUN.Abp.AspNetCore.HttpOverrides; |
|||
using LINGYUN.Abp.AspNetCore.MultiTenancy; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; |
|||
using LINGYUN.Abp.AuditLogging.Elasticsearch; |
|||
using LINGYUN.Abp.BlobStoring.OssManagement; |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.Emailing.Platform; |
|||
using LINGYUN.Abp.EventBus.CAP; |
|||
using LINGYUN.Abp.Exporter.MiniExcel; |
|||
using LINGYUN.Abp.Gdpr; |
|||
using LINGYUN.Abp.Gdpr.Web; |
|||
using LINGYUN.Abp.Identity.AspNetCore.Session; |
|||
using LINGYUN.Abp.Identity.OrganizaztionUnits; |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.OpenIddict.AspNetCore.Session; |
|||
using LINGYUN.Abp.OpenIddict.LinkUser; |
|||
using LINGYUN.Abp.OpenIddict.Portal; |
|||
using LINGYUN.Abp.OpenIddict.Sms; |
|||
using LINGYUN.Abp.OpenIddict.WeChat; |
|||
using LINGYUN.Abp.OpenIddict.WeChat.Work; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.Sms.Platform; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Caching.StackExchangeRedis; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.Identity; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSerilogEnrichersApplicationModule), |
|||
typeof(AbpSerilogEnrichersUniqueIdModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpAccountApplicationModule), |
|||
typeof(AbpAccountHttpApiModule), |
|||
typeof(AbpAccountWebOpenIddictModule), |
|||
typeof(AbpAccountWebOAuthModule), |
|||
typeof(AbpBlobStoringOssManagementModule), |
|||
typeof(AbpGdprApplicationModule), |
|||
typeof(AbpGdprHttpApiModule), |
|||
typeof(AbpGdprWebModule), |
|||
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpCachingStackExchangeRedisModule), |
|||
typeof(AbpIdentityAspNetCoreSessionModule), |
|||
typeof(AbpOpenIddictAspNetCoreSessionModule), |
|||
typeof(AbpIdentitySessionAspNetCoreModule), |
|||
typeof(AbpOpenIddictSmsModule), |
|||
typeof(AbpOpenIddictWeChatModule), |
|||
typeof(AbpOpenIddictLinkUserModule), |
|||
typeof(AbpOpenIddictPortalModule), |
|||
typeof(AbpOpenIddictWeChatWorkModule), |
|||
typeof(AbpIdentityOrganizaztionUnitsModule), |
|||
typeof(AbpPermissionManagementDomainIdentityModule), |
|||
typeof(AuthServerMigrationsEntityFrameworkCoreModule), |
|||
typeof(AbpDataDbMigratorModule), |
|||
typeof(AbpAuditLoggingElasticsearchModule), // 放在 AbpIdentity 模块之后,避免被覆盖
|
|||
typeof(AbpLocalizationCultureMapModule), |
|||
typeof(AbpAspNetCoreMultiTenancyModule), |
|||
typeof(AbpAspNetCoreMvcWrapperModule), |
|||
typeof(AbpAspNetCoreHttpOverridesModule), |
|||
typeof(AbpExporterMiniExcelModule), |
|||
typeof(AbpEmailingPlatformModule), |
|||
typeof(AbpSmsPlatformModule), |
|||
typeof(AbpCAPEventBusModule) |
|||
)] |
|||
public partial class AuthServerModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
|
|||
PreConfigureWrapper(); |
|||
PreConfigureFeature(); |
|||
PreForwardedHeaders(); |
|||
PreConfigureAuthServer(); |
|||
PreConfigureApp(configuration); |
|||
PreConfigureCAP(configuration); |
|||
PreConfigureCertificate(configuration, hostingEnvironment); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
ConfigureBranding(configuration); |
|||
ConfigureCaching(configuration); |
|||
ConfigureIdentity(configuration); |
|||
ConfigureVirtualFileSystem(); |
|||
ConfigureFeatureManagement(); |
|||
ConfigureSettingManagement(); |
|||
ConfigurePermissionManagement(); |
|||
ConfigureLocalization(); |
|||
ConfigureDataSeeder(); |
|||
ConfigureUrls(configuration); |
|||
ConfigureTiming(configuration); |
|||
ConfigureAuditing(configuration); |
|||
ConfigureAuthServer(configuration); |
|||
ConfigureMultiTenancy(configuration); |
|||
ConfigureJsonSerializer(configuration); |
|||
ConfigureMvc(context.Services, configuration); |
|||
ConfigureCors(context.Services, configuration); |
|||
ConfigureDistributedLocking(context.Services, configuration); |
|||
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); |
|||
} |
|||
|
|||
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|||
{ |
|||
await context.ServiceProvider |
|||
.GetRequiredService<IDataSeeder>() |
|||
.SeedAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,309 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using OpenIddict.Abstractions; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.OpenIddict.Applications; |
|||
using Volo.Abp.OpenIddict.Scopes; |
|||
using Volo.Abp.PermissionManagement; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer.DataSeeder; |
|||
|
|||
public class AuthServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
|||
{ |
|||
public static HashSet<string> InitializeScopes = new HashSet<string> |
|||
{ |
|||
// obsolete! microservice should be allocated separately
|
|||
"lingyun-abp-application", |
|||
// admin service
|
|||
"ams", |
|||
// identity service
|
|||
"ids", |
|||
// localization service
|
|||
"lts", |
|||
// platform service
|
|||
"pts", |
|||
// message service
|
|||
"mgs", |
|||
// task service
|
|||
"tks", |
|||
// webhook service
|
|||
"wks", |
|||
// workflow service
|
|||
"wfs", |
|||
// wechat service
|
|||
"was" |
|||
}; |
|||
|
|||
private readonly IConfiguration _configuration; |
|||
private readonly ICurrentTenant _currentTenant; |
|||
private readonly IOpenIddictApplicationManager _applicationManager; |
|||
private readonly IOpenIddictApplicationRepository _applicationRepository; |
|||
|
|||
private readonly IPermissionDataSeeder _permissionDataSeeder; |
|||
|
|||
private readonly IOpenIddictScopeManager _scopeManager; |
|||
private readonly IOpenIddictScopeRepository _scopeRepository; |
|||
|
|||
public AuthServerDataSeedContributor( |
|||
IConfiguration configuration, |
|||
ICurrentTenant currentTenant, |
|||
IOpenIddictScopeManager scopeManager, |
|||
IOpenIddictScopeRepository scopeRepository, |
|||
IPermissionDataSeeder permissionDataSeeder, |
|||
IOpenIddictApplicationManager applicationManager, |
|||
IOpenIddictApplicationRepository applicationRepository) |
|||
{ |
|||
_configuration = configuration; |
|||
_currentTenant = currentTenant; |
|||
_scopeManager = scopeManager; |
|||
_scopeRepository = scopeRepository; |
|||
_permissionDataSeeder = permissionDataSeeder; |
|||
_applicationManager = applicationManager; |
|||
_applicationRepository = applicationRepository; |
|||
} |
|||
|
|||
public async Task SeedAsync(DataSeedContext context) |
|||
{ |
|||
using (_currentTenant.Change(context.TenantId)) |
|||
{ |
|||
await CreateScopeAsync(InitializeScopes); |
|||
|
|||
await CreateApplicationAsync(InitializeScopes); |
|||
} |
|||
} |
|||
|
|||
private async Task CreateScopeAsync(IEnumerable<string> scopes) |
|||
{ |
|||
foreach (var scope in scopes) |
|||
{ |
|||
if (await _scopeRepository.FindByNameAsync(scope) == null) |
|||
{ |
|||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor() |
|||
{ |
|||
Name = scope, |
|||
DisplayName = scope + " access", |
|||
DisplayNames = |
|||
{ |
|||
[CultureInfo.GetCultureInfo("zh-Hans")] = "Abp API 应用程序访问", |
|||
[CultureInfo.GetCultureInfo("en")] = "Abp API Application Access" |
|||
}, |
|||
Resources = |
|||
{ |
|||
scope |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private async Task CreateApplicationAsync(IEnumerable<string> scopes) |
|||
{ |
|||
var configurationSection = _configuration.GetSection("OpenIddict:Applications"); |
|||
|
|||
var vueClientId = configurationSection["VueAdmin:ClientId"]; |
|||
if (!vueClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var vueClientRootUrl = configurationSection["VueAdmin:RootUrl"].EnsureEndsWith('/'); |
|||
|
|||
if (await _applicationRepository.FindByClientIdAsync(vueClientId) == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = vueClientId, |
|||
ClientSecret = configurationSection["VueAdmin:ClientSecret"], |
|||
ApplicationType = OpenIddictConstants.ApplicationTypes.Web, |
|||
ConsentType = OpenIddictConstants.ConsentTypes.Explicit, |
|||
DisplayName = "Abp Vue Admin Client", |
|||
PostLogoutRedirectUris = |
|||
{ |
|||
new Uri(vueClientRootUrl + "signout-callback"), |
|||
new Uri(vueClientRootUrl) |
|||
}, |
|||
RedirectUris = |
|||
{ |
|||
new Uri(vueClientRootUrl + "signin-callback"), |
|||
new Uri(vueClientRootUrl) |
|||
}, |
|||
Permissions = |
|||
{ |
|||
OpenIddictConstants.Permissions.Endpoints.Authorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Token, |
|||
OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Introspection, |
|||
OpenIddictConstants.Permissions.Endpoints.Revocation, |
|||
OpenIddictConstants.Permissions.Endpoints.EndSession, |
|||
|
|||
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.Permissions.GrantTypes.Implicit, |
|||
OpenIddictConstants.Permissions.GrantTypes.Password, |
|||
OpenIddictConstants.Permissions.GrantTypes.RefreshToken, |
|||
OpenIddictConstants.Permissions.GrantTypes.DeviceCode, |
|||
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials, |
|||
|
|||
OpenIddictConstants.Permissions.ResponseTypes.Code, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.None, |
|||
OpenIddictConstants.Permissions.ResponseTypes.Token, |
|||
|
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
} |
|||
}; |
|||
foreach (var scope in scopes) |
|||
{ |
|||
application.Permissions.AddIfNotContains(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
|
|||
var vueClientPermissions = new string[1] |
|||
{ |
|||
"AbpIdentity.UserLookup" |
|||
}; |
|||
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, vueClientId, vueClientPermissions); |
|||
} |
|||
} |
|||
|
|||
var internalServiceClientId = configurationSection["InternalService:ClientId"]; |
|||
if (!internalServiceClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
if (await _applicationRepository.FindByClientIdAsync(internalServiceClientId) == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = internalServiceClientId, |
|||
ClientSecret = configurationSection["InternalService:ClientSecret"], |
|||
ClientType = OpenIddictConstants.ClientTypes.Confidential, |
|||
ConsentType = OpenIddictConstants.ConsentTypes.Explicit, |
|||
ApplicationType = OpenIddictConstants.ApplicationTypes.Native, |
|||
DisplayName = "Abp Vue Admin Client", |
|||
Permissions = |
|||
{ |
|||
OpenIddictConstants.Permissions.Endpoints.Authorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Token, |
|||
OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Introspection, |
|||
OpenIddictConstants.Permissions.Endpoints.Revocation, |
|||
OpenIddictConstants.Permissions.Endpoints.EndSession, |
|||
|
|||
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.Permissions.GrantTypes.Implicit, |
|||
OpenIddictConstants.Permissions.GrantTypes.Password, |
|||
OpenIddictConstants.Permissions.GrantTypes.RefreshToken, |
|||
OpenIddictConstants.Permissions.GrantTypes.DeviceCode, |
|||
OpenIddictConstants.Permissions.GrantTypes.ClientCredentials, |
|||
|
|||
OpenIddictConstants.Permissions.ResponseTypes.Code, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.None, |
|||
OpenIddictConstants.Permissions.ResponseTypes.Token, |
|||
|
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
} |
|||
}; |
|||
foreach (var scope in scopes) |
|||
{ |
|||
application.Permissions.AddIfNotContains(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
|
|||
var internalServicePermissions = new string[2] |
|||
{ |
|||
"AbpIdentity.UserLookup","AbpIdentity.Users" |
|||
}; |
|||
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, internalServiceClientId, internalServicePermissions); |
|||
} |
|||
} |
|||
|
|||
var oauthClientId = configurationSection["VueOAuthClient:ClientId"]; |
|||
if (!oauthClientId.IsNullOrWhiteSpace()) |
|||
{ |
|||
var oauthClientRootUrls = configurationSection.GetSection("VueOAuthClient:RootUrls").Get<List<string>>(); |
|||
|
|||
if (await _applicationRepository.FindByClientIdAsync(oauthClientId) == null) |
|||
{ |
|||
var application = new OpenIddictApplicationDescriptor |
|||
{ |
|||
ClientId = oauthClientId, |
|||
ClientSecret = null, |
|||
ApplicationType = OpenIddictConstants.ApplicationTypes.Web, |
|||
ConsentType = OpenIddictConstants.ConsentTypes.Implicit, |
|||
DisplayName = "OAuth Client", |
|||
PostLogoutRedirectUris = { }, |
|||
RedirectUris = { }, |
|||
Permissions = |
|||
{ |
|||
OpenIddictConstants.Permissions.Endpoints.Authorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Token, |
|||
OpenIddictConstants.Permissions.Endpoints.DeviceAuthorization, |
|||
OpenIddictConstants.Permissions.Endpoints.Introspection, |
|||
OpenIddictConstants.Permissions.Endpoints.Revocation, |
|||
OpenIddictConstants.Permissions.Endpoints.EndSession, |
|||
|
|||
OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode, |
|||
OpenIddictConstants.Permissions.GrantTypes.RefreshToken, |
|||
|
|||
OpenIddictConstants.Permissions.ResponseTypes.Code, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.CodeToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken, |
|||
OpenIddictConstants.Permissions.ResponseTypes.None, |
|||
OpenIddictConstants.Permissions.ResponseTypes.Token, |
|||
|
|||
OpenIddictConstants.Permissions.Scopes.Roles, |
|||
OpenIddictConstants.Permissions.Scopes.Profile, |
|||
OpenIddictConstants.Permissions.Scopes.Email, |
|||
OpenIddictConstants.Permissions.Scopes.Address, |
|||
OpenIddictConstants.Permissions.Scopes.Phone, |
|||
} |
|||
}; |
|||
foreach (var scope in scopes) |
|||
{ |
|||
application.Permissions.AddIfNotContains(OpenIddictConstants.Permissions.Prefixes.Scope + scope); |
|||
} |
|||
|
|||
oauthClientRootUrls.ForEach(url => |
|||
{ |
|||
application.PostLogoutRedirectUris.AddIfNotContains(new Uri(url.EnsureEndsWith('/'))); |
|||
application.PostLogoutRedirectUris.AddIfNotContains(new Uri(url.EnsureEndsWith('/') + "signout-callback")); |
|||
|
|||
application.RedirectUris.AddIfNotContains(new Uri(url)); |
|||
application.RedirectUris.AddIfNotContains(new Uri(url.EnsureEndsWith('/') + "signin-callback")); |
|||
application.RedirectUris.AddIfNotContains(new Uri(url.EnsureEndsWith('/') + "swagger/oauth2-redirect.html")); |
|||
}); |
|||
|
|||
await _applicationManager.CreateAsync(application); |
|||
|
|||
var oauthClientPermissions = new string[1] |
|||
{ |
|||
"AbpIdentity.UserLookup" |
|||
}; |
|||
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, oauthClientId, oauthClientPermissions); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.AuthServer</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AgileConfig.Client" /> |
|||
<PackageReference Include="DotNetCore.CAP.Dashboard" /> |
|||
<PackageReference Include="DotNetCore.CAP.PostgreSql" /> |
|||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" /> |
|||
<PackageReference Include="DistributedLock.Redis" /> |
|||
<PackageReference Include="OpenIddict.Validation.DataProtection" /> |
|||
<PackageReference Include="OpenIddict.Server.DataProtection" /> |
|||
<PackageReference Include="Serilog.AspNetCore" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> |
|||
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
<PackageReference Include="Volo.Abp.Identity.AspNetCore" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> |
|||
<ProjectReference Include="..\..\framework\exporter\LINGYUN.Abp.Exporter.MiniExcel\LINGYUN.Abp.Exporter.MiniExcel.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.Localization.CultureMap\LINGYUN.Abp.Localization.CultureMap.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.Application\LINGYUN.Abp.Serilog.Enrichers.Application.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" /> |
|||
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" /> |
|||
<ProjectReference Include="..\..\framework\security\LINGYUN.Abp.Claims.Mapping\LINGYUN.Abp.Claims.Mapping.csproj" /> |
|||
<ProjectReference Include="..\..\framework\tenants\LINGYUN.Abp.AspNetCore.MultiTenancy\LINGYUN.Abp.AspNetCore.MultiTenancy.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.AuthServer.EntityFrameworkCore\LINGYUN.Abp.MicroService.AuthServer.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application\LINGYUN.Abp.Account.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Web.OAuth\LINGYUN.Abp.Account.Web.OAuth.csproj" /> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Web.OpenIddict\LINGYUN.Abp.Account.Web.OpenIddict.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.Application\LINGYUN.Abp.Gdpr.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.HttpApi\LINGYUN.Abp.Gdpr.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.Web\LINGYUN.Abp.Gdpr.Web.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.AspNetCore.Session\LINGYUN.Abp.Identity.AspNetCore.Session.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Session.AspNetCore\LINGYUN.Abp.Identity.Session.AspNetCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.AspNetCore.Session\LINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.LinkUser\LINGYUN.Abp.OpenIddict.LinkUser.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.Portal\LINGYUN.Abp.OpenIddict.Portal.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.Sms\LINGYUN.Abp.OpenIddict.Sms.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.WeChat.Work\LINGYUN.Abp.OpenIddict.WeChat.Work.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.WeChat\LINGYUN.Abp.OpenIddict.WeChat.csproj" /> |
|||
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.BlobStoring.OssManagement\LINGYUN.Abp.BlobStoring.OssManagement.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Emailing.Platform\LINGYUN.Abp.Emailing.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Sms.Platform\LINGYUN.Abp.Sms.Platform.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ServiceDefaults\LINGYUN.Abp.MicroService.ServiceDefaults.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Folder Include="wwwroot\" /> |
|||
</ItemGroup> |
|||
|
|||
<Target Name="RestoreNpmPackages" BeforeTargets="BeforeBuild"> |
|||
<Message Text="正在执行 abp install-libs ..." Importance="high" /> |
|||
|
|||
<PropertyGroup> |
|||
<PackageJsonPath>$(MSBuildProjectDirectory)\package.json</PackageJsonPath> |
|||
</PropertyGroup> |
|||
|
|||
<Exec Command="abp install-libs" |
|||
Condition="Exists('$(PackageJsonPath)')" |
|||
WorkingDirectory="$(MSBuildProjectDirectory)" |
|||
IgnoreExitCode="false" /> |
|||
</Target> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,70 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Http; |
|||
|
|||
namespace Microsoft.Extensions.DependencyInjection |
|||
{ |
|||
public static class SameSiteCookiesServiceCollectionExtensions |
|||
{ |
|||
public static IServiceCollection AddSameSiteCookiePolicy(this IServiceCollection services) |
|||
{ |
|||
services.Configure<CookiePolicyOptions>(options => |
|||
{ |
|||
options.MinimumSameSitePolicy = SameSiteMode.Unspecified; |
|||
options.OnAppendCookie = cookieContext => |
|||
CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); |
|||
options.OnDeleteCookie = cookieContext => |
|||
CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); |
|||
}); |
|||
|
|||
return services; |
|||
} |
|||
|
|||
private static void CheckSameSite(HttpContext httpContext, CookieOptions options) |
|||
{ |
|||
if (options.SameSite == SameSiteMode.None) |
|||
{ |
|||
var userAgent = httpContext.Request.Headers["User-Agent"].ToString(); |
|||
if (!httpContext.Request.IsHttps || DisallowsSameSiteNone(userAgent)) |
|||
{ |
|||
// For .NET Core < 3.1 set SameSite = (SameSiteMode)(-1)
|
|||
options.SameSite = SameSiteMode.Unspecified; |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static bool DisallowsSameSiteNone(string userAgent) |
|||
{ |
|||
// Cover all iOS based browsers here. This includes:
|
|||
// - Safari on iOS 12 for iPhone, iPod Touch, iPad
|
|||
// - WkWebview on iOS 12 for iPhone, iPod Touch, iPad
|
|||
// - Chrome on iOS 12 for iPhone, iPod Touch, iPad
|
|||
// All of which are broken by SameSite=None, because they use the iOS networking stack
|
|||
if (userAgent.Contains("CPU iPhone OS 12") || userAgent.Contains("iPad; CPU OS 12")) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
// Cover Mac OS X based browsers that use the Mac OS networking stack. This includes:
|
|||
// - Safari on Mac OS X.
|
|||
// This does not include:
|
|||
// - Chrome on Mac OS X
|
|||
// Because they do not use the Mac OS networking stack.
|
|||
if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") && |
|||
userAgent.Contains("Version/") && userAgent.Contains("Safari")) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
// Cover Chrome 50-69, because some versions are broken by SameSite=None,
|
|||
// and none in this range require it.
|
|||
// Note: this covers some pre-Chromium Edge versions,
|
|||
// but pre-Chromium Edge does not require SameSite=None.
|
|||
if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6")) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
@page |
|||
@using LINGYUN.Abp.MicroService.AuthServer.Pages |
|||
@using Volo.Abp.Users |
|||
@model IndexModel |
|||
@inject ICurrentUser CurrentUser |
|||
@if (CurrentUser.IsAuthenticated) |
|||
{ |
|||
<div> |
|||
<abp-row> |
|||
<abp-column size-md="_3" class="text-center"> |
|||
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i> |
|||
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">Logout</a> |
|||
</abp-column> |
|||
<abp-column size-md="_9"> |
|||
<h2>@CurrentUser.UserName</h2> |
|||
<h5 class="text-muted">@CurrentUser.Email</h5> |
|||
<div> |
|||
<strong>Roles</strong>: @CurrentUser.Roles.JoinAsString(", ") |
|||
<br /> |
|||
<strong>Claims</strong>: <br /> |
|||
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" <br /> ")) |
|||
</div> |
|||
</abp-column> |
|||
</abp-row> |
|||
</div> |
|||
} |
|||
|
|||
@if (!CurrentUser.IsAuthenticated) |
|||
{ |
|||
<div class="text-center"> |
|||
<i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br/><br /> |
|||
<a abp-button="Primary" asp-page="/Account/Login">Login</a> |
|||
</div> |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer.Pages; |
|||
|
|||
public class IndexModel : AbpPageModel |
|||
{ |
|||
public void OnGet() |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
|||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|||
@ -0,0 +1,95 @@ |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.MicroService.AuthServer; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.IO; |
|||
using Volo.Abp.IO; |
|||
using Volo.Abp.Modularity.PlugIns; |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting AuthServer Host..."); |
|||
|
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.ConfigureAppConfiguration((context, config) => |
|||
{ |
|||
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) |
|||
{ |
|||
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); |
|||
} |
|||
}) |
|||
.UseSerilog((context, provider, config) => |
|||
{ |
|||
config.ReadFrom.Configuration(context.Configuration); |
|||
}); |
|||
|
|||
builder.AddServiceDefaults(); |
|||
|
|||
await builder.AddApplicationAsync<AuthServerModule>(options => |
|||
{ |
|||
var applicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME") ?? "AuthServer"; |
|||
AbpSerilogEnrichersConsts.ApplicationName = applicationName; |
|||
options.ApplicationName = applicationName; |
|||
|
|||
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules"); |
|||
DirectoryHelper.CreateIfNotExists(pluginFolder); |
|||
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories); |
|||
}); |
|||
|
|||
var app = builder.Build(); |
|||
|
|||
await app.InitializeApplicationAsync(); |
|||
|
|||
app.MapDefaultEndpoints(); |
|||
|
|||
app.UseForwardedHeaders(); |
|||
app.UseMapRequestLocalization(); |
|||
if (app.Environment.IsDevelopment()) |
|||
{ |
|||
app.UseDeveloperExceptionPage(); |
|||
} |
|||
else |
|||
{ |
|||
// app.UseErrorPage();
|
|||
app.UseHsts(); |
|||
} |
|||
// app.UseHttpsRedirection();
|
|||
app.UseCookiePolicy(); |
|||
app.UseCorrelationId(); |
|||
app.MapAbpStaticAssets(); |
|||
app.UseRouting(); |
|||
app.UseCors(); |
|||
app.UseAuthentication(); |
|||
app.UseAbpOpenIddictValidation(); |
|||
app.UseMultiTenancy(); |
|||
app.UseAbpSession(); |
|||
app.UseUnitOfWork(); |
|||
app.UseDynamicClaims(); |
|||
app.UseAuthorization(); |
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
app.UseConfiguredEndpoints(); |
|||
|
|||
await app.RunAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
if (ex is HostAbortedException) |
|||
{ |
|||
throw; |
|||
} |
|||
|
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
{ |
|||
"profiles": { |
|||
"LINGYUN.Abp.MicroService.AuthServer": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "https://localhost:52861;http://localhost:52862" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
namespace LINGYUN.Abp.MicroService.AuthServer.Ui.Branding; |
|||
|
|||
public class AccountBrandingOptions |
|||
{ |
|||
public string AppName { get; set; } |
|||
|
|||
public string LogoUrl { get; set; } |
|||
|
|||
public string LogoReverseUrl { get; set; } |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Ui.Branding; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.AuthServer.Ui.Branding; |
|||
|
|||
[Dependency(ReplaceServices = true)] |
|||
[ExposeServices(typeof(IBrandingProvider), typeof(AccountBrandingProvider))] |
|||
public class AccountBrandingProvider : IBrandingProvider, ITransientDependency |
|||
{ |
|||
private readonly AccountBrandingOptions _options; |
|||
|
|||
public AccountBrandingProvider(IOptions<AccountBrandingOptions> options) |
|||
{ |
|||
_options = options.Value; |
|||
} |
|||
|
|||
public string AppName => _options.AppName ?? "MyApplication"; |
|||
|
|||
public string LogoUrl => _options.LogoUrl; |
|||
|
|||
public string LogoReverseUrl => _options.LogoReverseUrl; |
|||
} |
|||
@ -0,0 +1,185 @@ |
|||
{ |
|||
"App": { |
|||
"CorsOrigins": [ |
|||
"http://localhost:5666", |
|||
"http://localhost:30000", |
|||
"http://localhost:30010", |
|||
"http://localhost:30015", |
|||
"http://localhost:30020", |
|||
"http://localhost:30025", |
|||
"http://localhost:30030", |
|||
"http://localhost:30040", |
|||
"http://localhost:30045", |
|||
"http://localhost:30050", |
|||
"http://localhost:30060" |
|||
], |
|||
"Urls": { |
|||
"Applications": { |
|||
"MVC": { |
|||
"RootUrl": "http://localhost:44385/", |
|||
"Urls": { |
|||
"Abp.Account.EmailConfirm": "Account/EmailConfirm", |
|||
"Abp.Account.EmailVerifyLogin": "Account/VerifyCode" |
|||
} |
|||
}, |
|||
"STS": { |
|||
"RootUrl": "http://localhost:44385/" |
|||
}, |
|||
"VueVbenAdmin": { |
|||
"RootUrl": "http://localhost:5666/", |
|||
"Urls": { |
|||
"Abp.Account.EmailConfirm": "account/email-confirm", |
|||
"Abp.Account.EmailVerifyLogin": "account/verify-code" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"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=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"CAP": { |
|||
"EventBus": { |
|||
"DefaultGroupName": "AuthServer", |
|||
"Version": "v1", |
|||
"FailedRetryInterval": 300, |
|||
"FailedRetryCount": 10, |
|||
"CollectorCleaningInterval": 3600000 |
|||
}, |
|||
"PostgreSql": { |
|||
"TableNamePrefix": "auth", |
|||
"ConnectionString": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"RabbitMQ": { |
|||
"HostName": "localhost", |
|||
"Port": 5672, |
|||
"UserName": "admin", |
|||
"Password": "123456", |
|||
"ExchangeName": "LINGYUN.Abp.Application", |
|||
"VirtualHost": "/" |
|||
} |
|||
}, |
|||
"DistributedLock": { |
|||
"IsEnabled": true, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=13" |
|||
} |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=10", |
|||
"InstanceName": "LINGYUN.Abp.Application" |
|||
}, |
|||
"RemoteServices": { |
|||
"Platform": { |
|||
"BaseUrl": "http://localhost:30025", |
|||
"UseCurrentAccessToken": false |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://localhost:44385/", |
|||
"Audience": "lingyun-abp-application", |
|||
"MapInboundClaims": false, |
|||
"RequireHttpsMetadata": false |
|||
}, |
|||
"OpenIddict": { |
|||
"Applications": { |
|||
"VueAdmin": { |
|||
"ClientId": "vue-admin-client", |
|||
"ClientSecret": "1q2w3e*", |
|||
"RootUrl": "http://localhost:5666/" |
|||
}, |
|||
"InternalService": { |
|||
"ClientId": "InternalServiceClient", |
|||
"ClientSecret": "1q2w3e*" |
|||
}, |
|||
"VueOAuthClient": { |
|||
"ClientId": "vue-oauth-client", |
|||
"RootUrls": [ |
|||
"http://localhost:5666", |
|||
"http://localhost:30010", |
|||
"http://localhost:30015", |
|||
"http://localhost:30020", |
|||
"http://localhost:30025", |
|||
"http://localhost:30030", |
|||
"http://localhost:30040", |
|||
"http://localhost:30045", |
|||
"http://localhost:30050", |
|||
"http://localhost:30060" |
|||
] |
|||
} |
|||
} |
|||
}, |
|||
"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 |
|||
} |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://localhost:9200" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Warning", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Warning" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"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://localhost:9200", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
{ |
|||
"App": { |
|||
"Branding": { |
|||
"AppName": "Auth Server" |
|||
}, |
|||
"SslFile": "openiddict.pfx", |
|||
"SslPassword": "e1c48393-0c43-11f0-9582-4aecacda42db" |
|||
}, |
|||
"Clock": { |
|||
"Kind": "Local" |
|||
}, |
|||
"Forwarded": { |
|||
"ForwardedHeaders": "XForwardedFor,XForwardedProto" |
|||
}, |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"Json": { |
|||
"InputDateTimeFormats": [ |
|||
"yyyy-MM-dd HH:mm:ss", |
|||
"yyyy-MM-ddTHH:mm:ss" |
|||
] |
|||
}, |
|||
"SkyWalking": { |
|||
"Enable": false |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Information" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
{ |
|||
"version": "9.3.6", |
|||
"name": "my-app-authserver", |
|||
"private": true, |
|||
"dependencies": { |
|||
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "4.3.6", |
|||
"@abp/qrcode": "9.3.6" |
|||
} |
|||
} |
|||
@ -0,0 +1,164 @@ |
|||
using LINGYUN.Abp.Identity; |
|||
using LINGYUN.Abp.Identity.Session; |
|||
using LINGYUN.Abp.Identity.Settings; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Settings; |
|||
using Volo.Abp.Uow; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.IdentityService.Handlers; |
|||
/// <summary>
|
|||
/// 会话控制事件处理器
|
|||
/// </summary>
|
|||
public class IdentitySessionAccessEventHandler : |
|||
IDistributedEventHandler<IdentitySessionChangeAccessedEvent>, |
|||
IDistributedEventHandler<EntityCreatedEto<IdentitySessionEto>>, |
|||
IDistributedEventHandler<EntityDeletedEto<UserEto>>, |
|||
ITransientDependency |
|||
{ |
|||
public ILogger<IdentitySessionAccessEventHandler> Logger { protected get; set; } |
|||
protected ISettingProvider SettingProvider { get; } |
|||
protected IAbpDistributedLock DistributedLock { get; } |
|||
protected IIdentitySessionCache IdentitySessionCache { get; } |
|||
protected IIdentitySessionStore IdentitySessionStore { get; } |
|||
|
|||
public IdentitySessionAccessEventHandler( |
|||
ISettingProvider settingProvider, |
|||
IAbpDistributedLock distributedLock, |
|||
IIdentitySessionCache identitySessionCache, |
|||
IIdentitySessionStore identitySessionStore) |
|||
{ |
|||
SettingProvider = settingProvider; |
|||
DistributedLock = distributedLock; |
|||
IdentitySessionCache = identitySessionCache; |
|||
IdentitySessionStore = identitySessionStore; |
|||
|
|||
Logger = NullLogger<IdentitySessionAccessEventHandler>.Instance; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public async virtual Task HandleEventAsync(EntityCreatedEto<IdentitySessionEto> eventData) |
|||
{ |
|||
// 新会话创建时检查登录策略
|
|||
var lockKey = $"{nameof(IdentitySessionAccessEventHandler)}_{nameof(EntityCreatedEto<IdentitySessionEto>)}"; |
|||
await using (var handle = await DistributedLock.TryAcquireAsync(lockKey)) |
|||
{ |
|||
Logger.LogInformation($"Lock is acquired for {lockKey}"); |
|||
|
|||
if (handle == null) |
|||
{ |
|||
Logger.LogInformation($"Handle is null because of the locking for : {lockKey}"); |
|||
return; |
|||
} |
|||
|
|||
await CheckConcurrentLoginStrategy(eventData.Entity); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public async virtual Task HandleEventAsync(EntityDeletedEto<UserEto> eventData) |
|||
{ |
|||
// 用户被删除, 移除所有会话
|
|||
var lockKey = $"{nameof(IdentitySessionAccessEventHandler)}_{nameof(EntityDeletedEto<UserEto>)}"; |
|||
await using (var handle = await DistributedLock.TryAcquireAsync(lockKey)) |
|||
{ |
|||
Logger.LogInformation($"Lock is acquired for {lockKey}"); |
|||
|
|||
if (handle == null) |
|||
{ |
|||
Logger.LogInformation($"Handle is null because of the locking for : {lockKey}"); |
|||
return; |
|||
} |
|||
|
|||
await IdentitySessionStore.RevokeAllAsync(eventData.Entity.Id); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public async virtual Task HandleEventAsync(IdentitySessionChangeAccessedEvent eventData) |
|||
{ |
|||
// 会话访问更新
|
|||
var lockKey = $"{nameof(IdentitySessionAccessEventHandler)}_{nameof(IdentitySessionChangeAccessedEvent)}"; |
|||
await using (var handle = await DistributedLock.TryAcquireAsync(lockKey)) |
|||
{ |
|||
Logger.LogInformation($"Lock is acquired for {lockKey}"); |
|||
|
|||
if (handle == null) |
|||
{ |
|||
Logger.LogInformation($"Handle is null because of the locking for : {lockKey}"); |
|||
return; |
|||
} |
|||
|
|||
var idetitySession = await IdentitySessionStore.FindAsync(eventData.SessionId); |
|||
if (idetitySession != null) |
|||
{ |
|||
if (!eventData.IpAddresses.IsNullOrWhiteSpace()) |
|||
{ |
|||
idetitySession.SetIpAddresses(eventData.IpAddresses.Split(",")); |
|||
} |
|||
idetitySession.UpdateLastAccessedTime(eventData.LastAccessed); |
|||
|
|||
await IdentitySessionStore.UpdateAsync(idetitySession); |
|||
} |
|||
else |
|||
{ |
|||
// 数据库中不存在会话, 清理缓存, 后续请求会话失效
|
|||
await IdentitySessionCache.RemoveAsync(eventData.SessionId); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected async virtual Task CheckConcurrentLoginStrategy(IdentitySessionEto session) |
|||
{ |
|||
// 创建一个会话后根据策略使其他会话失效
|
|||
var strategySet = await SettingProvider.GetOrNullAsync(IdentitySettingNames.Session.ConcurrentLoginStrategy); |
|||
|
|||
Logger.LogDebug($"The concurrent login strategy is: {strategySet}"); |
|||
|
|||
if (!strategySet.IsNullOrWhiteSpace() && Enum.TryParse<ConcurrentLoginStrategy>(strategySet, true, out var strategy)) |
|||
{ |
|||
switch (strategy) |
|||
{ |
|||
// 限制用户相同设备
|
|||
case ConcurrentLoginStrategy.LogoutFromSameTypeDevicesLimit: |
|||
|
|||
var sameTypeDevicesCountSet = await SettingProvider.GetAsync(IdentitySettingNames.Session.LogoutFromSameTypeDevicesLimit, 1); |
|||
|
|||
Logger.LogDebug($"Clear other sessions on the device {session.Device} and save only {sameTypeDevicesCountSet} sessions."); |
|||
|
|||
await IdentitySessionStore.RevokeWithAsync( |
|||
session.UserId, |
|||
session.Device, |
|||
session.Id, |
|||
sameTypeDevicesCountSet); |
|||
break; |
|||
// 限制登录设备
|
|||
case ConcurrentLoginStrategy.LogoutFromSameTypeDevices: |
|||
|
|||
Logger.LogDebug($"Clear all other sessions on the device {session.Device}."); |
|||
|
|||
await IdentitySessionStore.RevokeAllAsync( |
|||
session.UserId, |
|||
session.Device, |
|||
session.Id); |
|||
break; |
|||
// 限制多端登录
|
|||
case ConcurrentLoginStrategy.LogoutFromAllDevices: |
|||
|
|||
Logger.LogDebug($"Clear all other user sessions."); |
|||
|
|||
await IdentitySessionStore.RevokeAllAsync( |
|||
session.UserId, |
|||
session.Id); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,450 @@ |
|||
using DotNetCore.CAP; |
|||
using LINGYUN.Abp.BlobStoring.OssManagement; |
|||
using LINGYUN.Abp.Identity.Session; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.LocalizationManagement; |
|||
using LINGYUN.Abp.OpenIddict.Permissions; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.Wrapper; |
|||
using Medallion.Threading; |
|||
using Medallion.Threading.Redis; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.Cors; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.Extensions.Caching.StackExchangeRedis; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.IdentityModel.Logging; |
|||
using Microsoft.IdentityModel.Tokens; |
|||
using Microsoft.OpenApi.Models; |
|||
using StackExchange.Redis; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Encodings.Web; |
|||
using System.Text.Unicode; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Auditing; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.FeatureManagement; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Json; |
|||
using Volo.Abp.Json.SystemTextJson; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Security.Claims; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.Timing; |
|||
using Volo.Abp.UI.Navigation.Urls; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.IdentityService; |
|||
|
|||
public partial class IdentityServiceModule |
|||
{ |
|||
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
|||
|
|||
private void PreConfigureFeature() |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); |
|||
}); |
|||
} |
|||
|
|||
private void PreForwardedHeaders() |
|||
{ |
|||
} |
|||
|
|||
private void PreConfigureApp(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options => |
|||
{ |
|||
// 以开放端口区别,应在0-31之间
|
|||
options.SnowflakeIdOptions.WorkerId = 15; |
|||
options.SnowflakeIdOptions.WorkerIdBits = 5; |
|||
options.SnowflakeIdOptions.DatacenterId = 1; |
|||
}); |
|||
|
|||
if (configuration.GetValue<bool>("App:ShowPii")) |
|||
{ |
|||
IdentityModelEventSource.ShowPII = true; |
|||
} |
|||
} |
|||
|
|||
private void PreConfigureCAP(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<CapOptions>(options => |
|||
{ |
|||
options |
|||
.UsePostgreSql(mySqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:PostgreSql").Bind(mySqlOptions); |
|||
}) |
|||
.UseRabbitMQ(rabbitMQOptions => |
|||
{ |
|||
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
|||
}) |
|||
.UseDashboard(); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureIdentity() |
|||
{ |
|||
PreConfigure<IdentityBuilder>(builder => |
|||
{ |
|||
builder.AddDefaultTokenProviders(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureBlobStoring(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpBlobStoringOptions>(options => |
|||
{ |
|||
// all container use oss management
|
|||
options.Containers.ConfigureAll((containerName, containerConfiguration) => |
|||
{ |
|||
// use oss management
|
|||
containerConfiguration.UseOssManagement(config => |
|||
{ |
|||
config.Bucket = configuration[OssManagementBlobProviderConfigurationNames.Bucket]; |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDbContext() |
|||
{ |
|||
// 配置Ef
|
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.UseNpgsql(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureJsonSerializer(IConfiguration configuration) |
|||
{ |
|||
// 统一时间日期格式
|
|||
Configure<AbpJsonOptions>(options => |
|||
{ |
|||
var jsonConfiguration = configuration.GetSection("Json"); |
|||
if (jsonConfiguration.Exists()) |
|||
{ |
|||
jsonConfiguration.Bind(options); |
|||
} |
|||
}); |
|||
// 中文序列化的编码问题
|
|||
Configure<AbpSystemTextJsonSerializerOptions>(options => |
|||
{ |
|||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureFeatureManagement() |
|||
{ |
|||
Configure<FeatureManagementOptions>(options => |
|||
{ |
|||
options.IsDynamicFeatureStoreEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigurePermissionManagement() |
|||
{ |
|||
Configure<PermissionManagementOptions>(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; |
|||
options.SaveStaticPermissionsToDatabase = false; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAuditing(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
// 是否启用实体变更记录
|
|||
var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; |
|||
if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || |
|||
(bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) |
|||
{ |
|||
options.EntityHistorySelectors.AddAllEntities(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureUrls(IConfiguration configuration) |
|||
{ |
|||
Configure<AppUrlOptions>(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 ConfigureDistributedLocking(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
var distributedLockEnabled = configuration["DistributedLock:IsEnabled"]; |
|||
if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) |
|||
{ |
|||
services.AddSingleton<IDistributedLockProvider>(sp => |
|||
{ |
|||
var connectionMultiplexer = sp.GetRequiredService<IConnectionMultiplexer>(); |
|||
return new RedisDistributedSynchronizationProvider(connectionMultiplexer.GetDatabase()); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureTiming(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpClockOptions>(options => |
|||
{ |
|||
configuration.GetSection("Clock").Bind(options); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCaching(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpDistributedCacheOptions>(options => |
|||
{ |
|||
configuration.GetSection("DistributedCache").Bind(options); |
|||
}); |
|||
|
|||
Configure<AbpDistributedEntityEventOptions>(options => |
|||
{ |
|||
options.AutoEventSelectors.AddNamespace("Volo.Abp.Identity"); |
|||
options.AutoEventSelectors.AddNamespace("Volo.Abp.OpenIddict"); |
|||
}); |
|||
|
|||
Configure<RedisCacheOptions>(options => |
|||
{ |
|||
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
|||
options.ConfigurationOptions = redisConfig; |
|||
options.InstanceName = configuration["Redis:InstanceName"]; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureMvc(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAspNetCoreMvcOptions>(options => |
|||
{ |
|||
options.ExposeIntegrationServices = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureVirtualFileSystem() |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<IdentityServiceModule>("LINGYUN.Abp.MicroService.IdentityService"); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureMultiTenancy(IConfiguration configuration) |
|||
{ |
|||
// 多租户
|
|||
Configure<AbpMultiTenancyOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
|
|||
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
|||
if (tenantResolveCfg.Exists()) |
|||
{ |
|||
Configure<AbpTenantResolveOptions>(options => |
|||
{ |
|||
var domains = tenantResolveCfg.Get<string[]>(); |
|||
foreach (var domain in domains) |
|||
{ |
|||
options.AddDomainTenantResolver(domain); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureIdentity() |
|||
{ |
|||
Configure<AbpClaimsPrincipalFactoryOptions>(options => |
|||
{ |
|||
options.IsDynamicClaimsEnabled = true; |
|||
}); |
|||
Configure<IdentitySessionCleanupOptions>(options => |
|||
{ |
|||
options.IsCleanupEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSwagger(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
// Swagger
|
|||
services.AddAbpSwaggerGenWithOAuth( |
|||
configuration["AuthServer:Authority"], |
|||
new Dictionary<string, string> |
|||
{ |
|||
{ configuration["AuthServer:Audience"], "Identity Service API"} |
|||
}, |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo |
|||
{ |
|||
Title = "Identity Service API", Version = "v1", |
|||
Contact = new OpenApiContact |
|||
{ |
|||
Name = "colin", |
|||
Email = "colin.in@foxmail.com", |
|||
Url = new Uri("https://github.com/colinin") |
|||
}, |
|||
License = new OpenApiLicense |
|||
{ |
|||
Name = "MIT", |
|||
Url = new Uri("https://github.com/colinin/abp-next-admin/blob/master/LICENSE") |
|||
} |
|||
}); |
|||
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<TenantHeaderParamter>(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureLocalization() |
|||
{ |
|||
// 支持本地化语言类型
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationCultureMapOptions>(options => |
|||
{ |
|||
var zhHansCultureMapInfo = new CultureMapInfo |
|||
{ |
|||
TargetCulture = "zh-Hans", |
|||
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
|||
}; |
|||
|
|||
options.CulturesMaps.Add(zhHansCultureMapInfo); |
|||
options.UiCulturesMaps.Add(zhHansCultureMapInfo); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationManagementOptions>(options => |
|||
{ |
|||
options.SaveStaticLocalizationsToDatabase = true; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCors(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
services.AddCors(options => |
|||
{ |
|||
options.AddDefaultPolicy(builder => |
|||
{ |
|||
var corsOrigins = configuration.GetSection("App:CorsOrigins").Get<List<string>>(); |
|||
if (corsOrigins == null || corsOrigins.Count == 0) |
|||
{ |
|||
corsOrigins = configuration["App:CorsOrigins"]? |
|||
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToList() ?? new List<string>(); |
|||
} |
|||
builder |
|||
.WithOrigins(corsOrigins |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToArray() |
|||
) |
|||
.WithAbpExposedHeaders() |
|||
.WithAbpWrapExposedHeaders() |
|||
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|||
.AllowAnyHeader() |
|||
.AllowAnyMethod() |
|||
.AllowCredentials(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
|||
{ |
|||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
|||
.AddAbpJwtBearer(options => |
|||
{ |
|||
configuration.GetSection("AuthServer").Bind(options); |
|||
|
|||
var validIssuers = configuration.GetSection("AuthServer:ValidIssuers").Get<List<string>>(); |
|||
if (validIssuers?.Count > 0) |
|||
{ |
|||
options.TokenValidationParameters.ValidIssuers = validIssuers; |
|||
options.TokenValidationParameters.IssuerValidator = TokenWildcardIssuerValidator.IssuerValidator; |
|||
} |
|||
var validAudiences = configuration.GetSection("AuthServer:ValidAudiences").Get<List<string>>(); |
|||
if (validAudiences?.Count > 0) |
|||
{ |
|||
options.TokenValidationParameters.ValidAudiences = validAudiences; |
|||
} |
|||
}); |
|||
|
|||
services |
|||
.AddDataProtection() |
|||
.SetApplicationName("LINGYUN.Abp.Application") |
|||
.PersistKeysToStackExchangeRedis(() => |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); |
|||
|
|||
return redis.GetDatabase(); |
|||
}, |
|||
"LINGYUN.Abp.Application:DataProtection:Protection-Keys"); |
|||
} |
|||
|
|||
private void ConfigureWrapper() |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureWrapper() |
|||
{ |
|||
// 服务间调用不包装
|
|||
PreConfigure<AbpHttpClientBuilderOptions>(options => |
|||
{ |
|||
options.ProxyClientActions.Add( |
|||
(_, _, client) => |
|||
{ |
|||
client.DefaultRequestHeaders.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
using LINGYUN.Abp.Account; |
|||
using LINGYUN.Abp.AspNetCore.HttpOverrides; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Localization; |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; |
|||
using LINGYUN.Abp.AuditLogging.Elasticsearch; |
|||
using LINGYUN.Abp.Authorization.OrganizationUnits; |
|||
using LINGYUN.Abp.BlobStoring.OssManagement; |
|||
using LINGYUN.Abp.Claims.Mapping; |
|||
using LINGYUN.Abp.Emailing.Platform; |
|||
using LINGYUN.Abp.EventBus.CAP; |
|||
using LINGYUN.Abp.ExceptionHandling.Emailing; |
|||
using LINGYUN.Abp.Exporter.MiniExcel; |
|||
using LINGYUN.Abp.Gdpr; |
|||
using LINGYUN.Abp.Gdpr.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Gdpr.Identity; |
|||
using LINGYUN.Abp.Identity; |
|||
using LINGYUN.Abp.Identity.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.OpenIddict; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.Sms.Platform; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
using Volo.Abp.AspNetCore.MultiTenancy; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Caching.StackExchangeRedis; |
|||
using Volo.Abp.EntityFrameworkCore.PostgreSql; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Swashbuckle; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.IdentityService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSerilogEnrichersApplicationModule), |
|||
typeof(AbpSerilogEnrichersUniqueIdModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpAspNetCoreMultiTenancyModule), |
|||
typeof(AbpAspNetCoreMvcLocalizationModule), |
|||
typeof(AbpAccountApplicationModule), |
|||
typeof(AbpAccountHttpApiModule), |
|||
typeof(AbpIdentityApplicationModule), |
|||
typeof(AbpIdentityHttpApiModule), |
|||
typeof(AbpIdentityEntityFrameworkCoreModule), |
|||
typeof(AbpOpenIddictApplicationModule), |
|||
typeof(AbpOpenIddictHttpApiModule), |
|||
typeof(AbpOpenIddictEntityFrameworkCoreModule), |
|||
typeof(AbpGdprApplicationModule), |
|||
typeof(AbpGdprHttpApiModule), |
|||
typeof(AbpGdprDomainIdentityModule), |
|||
typeof(AbpGdprEntityFrameworkCoreModule), |
|||
typeof(AbpEntityFrameworkCorePostgreSqlModule), |
|||
typeof(AbpSaasEntityFrameworkCoreModule), |
|||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
|||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
|||
typeof(AbpAuthorizationOrganizationUnitsModule), |
|||
typeof(AbpAuditLoggingElasticsearchModule), |
|||
typeof(AbpEmailingExceptionHandlingModule), |
|||
typeof(AbpBlobStoringOssManagementModule), |
|||
typeof(AbpCAPEventBusModule), |
|||
typeof(AbpHttpClientModule), |
|||
typeof(AbpSmsPlatformModule), |
|||
typeof(AbpEmailingPlatformModule), |
|||
typeof(AbpCachingStackExchangeRedisModule), |
|||
typeof(AbpLocalizationCultureMapModule), |
|||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
|||
typeof(AbpIdentitySessionAspNetCoreModule), |
|||
typeof(AbpAspNetCoreHttpOverridesModule), |
|||
typeof(AbpAspNetCoreMvcWrapperModule), |
|||
typeof(AbpExporterMiniExcelModule), |
|||
typeof(AbpClaimsMappingModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpAutofacModule) |
|||
)] |
|||
public partial class IdentityServiceModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|||
|
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
PreConfigureWrapper(); |
|||
PreConfigureFeature(); |
|||
PreForwardedHeaders(); |
|||
PreConfigureApp(configuration); |
|||
PreConfigureCAP(configuration); |
|||
PreConfigureIdentity(); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
ConfigureWrapper(); |
|||
ConfigureIdentity(); |
|||
ConfigureDbContext(); |
|||
ConfigureLocalization(); |
|||
ConfigureVirtualFileSystem(); |
|||
ConfigureFeatureManagement(); |
|||
ConfigurePermissionManagement(); |
|||
ConfigureBlobStoring(configuration); |
|||
ConfigureUrls(configuration); |
|||
ConfigureCaching(configuration); |
|||
ConfigureTiming(configuration); |
|||
ConfigureAuditing(configuration); |
|||
ConfigureMultiTenancy(configuration); |
|||
ConfigureJsonSerializer(configuration); |
|||
ConfigureMvc(context.Services, configuration); |
|||
ConfigureCors(context.Services, configuration); |
|||
ConfigureSwagger(context.Services, configuration); |
|||
ConfigureDistributedLocking(context.Services, configuration); |
|||
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.IdentityService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AgileConfig.Client" /> |
|||
<PackageReference Include="DotNetCore.CAP.Dashboard" /> |
|||
<PackageReference Include="DotNetCore.CAP.PostgreSql" /> |
|||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" /> |
|||
<PackageReference Include="DistributedLock.Redis" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> |
|||
<PackageReference Include="Serilog.AspNetCore" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" /> |
|||
<PackageReference Include="Volo.Abp.Account.Application" /> |
|||
<PackageReference Include="Volo.Abp.Account.HttpApi" /> |
|||
<PackageReference Include="Volo.Abp.Http.Client" /> |
|||
<PackageReference Include="Volo.Abp.Identity.AspNetCore" /> |
|||
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\authorization\LINGYUN.Abp.Authorization.OrganizationUnits\LINGYUN.Abp.Authorization.OrganizationUnits.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.ExceptionHandling.Emailing\LINGYUN.Abp.ExceptionHandling.Emailing.csproj" /> |
|||
<ProjectReference Include="..\..\framework\exporter\LINGYUN.Abp.Exporter.MiniExcel\LINGYUN.Abp.Exporter.MiniExcel.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.AspNetCore.Mvc.Localization\LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.Localization.CultureMap\LINGYUN.Abp.Localization.CultureMap.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.Application\LINGYUN.Abp.Serilog.Enrichers.Application.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" /> |
|||
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" /> |
|||
<ProjectReference Include="..\..\framework\security\LINGYUN.Abp.Claims.Mapping\LINGYUN.Abp.Claims.Mapping.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application\LINGYUN.Abp.Account.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.Application\LINGYUN.Abp.Gdpr.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.Domain.Identity\LINGYUN.Abp.Gdpr.Domain.Identity.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.EntityFrameworkCore\LINGYUN.Abp.Gdpr.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\gdpr\LINGYUN.Abp.Gdpr.HttpApi\LINGYUN.Abp.Gdpr.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Session.AspNetCore\LINGYUN.Abp.Identity.Session.AspNetCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.Application\LINGYUN.Abp.OpenIddict.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\openIddict\LINGYUN.Abp.OpenIddict.HttpApi\LINGYUN.Abp.OpenIddict.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Application\LINGYUN.Abp.Identity.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.HttpApi\LINGYUN.Abp.Identity.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.BlobStoring.OssManagement\LINGYUN.Abp.BlobStoring.OssManagement.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Emailing.Platform\LINGYUN.Abp.Emailing.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Sms.Platform\LINGYUN.Abp.Sms.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ServiceDefaults\LINGYUN.Abp.MicroService.ServiceDefaults.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,105 @@ |
|||
using LINGYUN.Abp.Identity.Session.AspNetCore; |
|||
using LINGYUN.Abp.MicroService.IdentityService; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.IO; |
|||
using Volo.Abp.IO; |
|||
using Volo.Abp.Modularity.PlugIns; |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting IdentityService Host..."); |
|||
|
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.ConfigureAppConfiguration((context, config) => |
|||
{ |
|||
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false)) |
|||
{ |
|||
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration)); |
|||
} |
|||
}) |
|||
.UseSerilog((context, provider, config) => |
|||
{ |
|||
config.ReadFrom.Configuration(context.Configuration); |
|||
}); |
|||
|
|||
builder.AddServiceDefaults(); |
|||
|
|||
await builder.AddApplicationAsync<IdentityServiceModule>(options => |
|||
{ |
|||
var applicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME") ?? "IdentityService"; |
|||
AbpSerilogEnrichersConsts.ApplicationName = applicationName; |
|||
options.ApplicationName = applicationName; |
|||
|
|||
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules"); |
|||
DirectoryHelper.CreateIfNotExists(pluginFolder); |
|||
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories); |
|||
}); |
|||
|
|||
var app = builder.Build(); |
|||
|
|||
await app.InitializeApplicationAsync(); |
|||
|
|||
app.MapDefaultEndpoints(); |
|||
|
|||
app.UseForwardedHeaders(); |
|||
// 本地化
|
|||
app.UseMapRequestLocalization(); |
|||
// http调用链
|
|||
app.UseCorrelationId(); |
|||
// 虚拟文件系统
|
|||
app.MapAbpStaticAssets(); |
|||
// 路由
|
|||
app.UseRouting(); |
|||
// 跨域
|
|||
app.UseCors(); |
|||
// 认证
|
|||
app.UseAuthentication(); |
|||
// 多租户
|
|||
app.UseMultiTenancy(); |
|||
// 会话
|
|||
app.UseAbpSession(); |
|||
// 动态身份
|
|||
app.UseDynamicClaims(); |
|||
// 授权
|
|||
app.UseAuthorization(); |
|||
// Swagger
|
|||
app.UseSwagger(); |
|||
// Swagger可视化界面
|
|||
app.UseAbpSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Identity Service API"); |
|||
|
|||
var configuration = app.Configuration; |
|||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); |
|||
options.OAuthScopes(configuration["AuthServer:Audience"]); |
|||
}); |
|||
// 审计日志
|
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
// 路由
|
|||
app.UseConfiguredEndpoints(); |
|||
|
|||
await app.RunAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
if (ex is HostAbortedException) |
|||
{ |
|||
throw; |
|||
} |
|||
|
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
{ |
|||
"profiles": { |
|||
"LINGYUN.Abp.MicroService.IdentityService": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "https://localhost:60708;http://localhost:60709" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Microsoft.OpenApi.Models; |
|||
using Swashbuckle.AspNetCore.SwaggerGen; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.AspNetCore.MultiTenancy; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.IdentityService; |
|||
|
|||
public class TenantHeaderParamter : IOperationFilter |
|||
{ |
|||
private readonly AbpMultiTenancyOptions _multiTenancyOptions; |
|||
private readonly AbpAspNetCoreMultiTenancyOptions _aspNetCoreMultiTenancyOptions; |
|||
public TenantHeaderParamter( |
|||
IOptions<AbpMultiTenancyOptions> multiTenancyOptions, |
|||
IOptions<AbpAspNetCoreMultiTenancyOptions> aspNetCoreMultiTenancyOptions) |
|||
{ |
|||
_multiTenancyOptions = multiTenancyOptions.Value; |
|||
_aspNetCoreMultiTenancyOptions = aspNetCoreMultiTenancyOptions.Value; |
|||
} |
|||
|
|||
public void Apply(OpenApiOperation operation, OperationFilterContext context) |
|||
{ |
|||
if (_multiTenancyOptions.IsEnabled) |
|||
{ |
|||
operation.Parameters = operation.Parameters ?? new List<OpenApiParameter>(); |
|||
operation.Parameters.Add(new OpenApiParameter |
|||
{ |
|||
Name = _aspNetCoreMultiTenancyOptions.TenantKey, |
|||
In = ParameterLocation.Header, |
|||
Description = "Tenant Id in http header", |
|||
Required = false |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,131 @@ |
|||
{ |
|||
"App": { |
|||
"ShowPii": true, |
|||
"CorsOrigins": [ "http://localhost:5666", "http://localhost:30000" ], |
|||
"Urls": { |
|||
"Applications": { |
|||
"MVC": { |
|||
"RootUrl": "http://localhost:44385/", |
|||
"Urls": { |
|||
"Abp.Account.EmailConfirm": "Account/EmailConfirm", |
|||
"Abp.Account.EmailVerifyLogin": "Account/VerifyCode" |
|||
} |
|||
}, |
|||
"STS": { |
|||
"RootUrl": "http://localhost:44385/" |
|||
}, |
|||
"VueVbenAdmin": { |
|||
"RootUrl": "http://localhost:3100/", |
|||
"Urls": { |
|||
"Abp.Account.EmailConfirm": "account/email-confirm", |
|||
"Abp.Account.EmailVerifyLogin": "account/verify-code" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
"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=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"CAP": { |
|||
"EventBus": { |
|||
"DefaultGroupName": "IdentityService", |
|||
"Version": "v1", |
|||
"FailedRetryInterval": 300, |
|||
"FailedRetryCount": 10, |
|||
"CollectorCleaningInterval": 3600000 |
|||
}, |
|||
"PostgreSql": { |
|||
"TableNamePrefix": "ida", |
|||
"ConnectionString": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
}, |
|||
"RabbitMQ": { |
|||
"HostName": "localhost", |
|||
"Port": 5672, |
|||
"UserName": "admin", |
|||
"Password": "123456", |
|||
"ExchangeName": "LINGYUN.Abp.Application", |
|||
"VirtualHost": "/" |
|||
} |
|||
}, |
|||
"DistributedLock": { |
|||
"IsEnabled": true, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=13" |
|||
} |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,defaultDatabase=10", |
|||
"InstanceName": "LINGYUN.Abp.Application" |
|||
}, |
|||
"RemoteServices": { |
|||
"Platform": { |
|||
"BaseUrl": "http://localhost:30025", |
|||
"UseCurrentAccessToken": false |
|||
} |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://localhost:44385", |
|||
"Audience": "lingyun-abp-application", |
|||
"MapInboundClaims": false, |
|||
"RequireHttpsMetadata": false, |
|||
"SwaggerClientId": "vue-oauth-client" |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"OssManagement": { |
|||
"Bucket": "users" |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://elasticsearch" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"System": "Information", |
|||
"Microsoft": "Information", |
|||
"DotNetCore": "Warning" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"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://localhost:9200", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,98 @@ |
|||
{ |
|||
"Clock": { |
|||
"Kind": "Local" |
|||
}, |
|||
"Forwarded": { |
|||
"ForwardedHeaders": "XForwardedFor,XForwardedProto" |
|||
}, |
|||
"App": { |
|||
"CorsOrigins": "http://localhost:3100" |
|||
}, |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"Json": { |
|||
"OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", |
|||
"InputDateTimeFormats": [ |
|||
"yyyy-MM-dd HH:mm:ss", |
|||
"yyyy-MM-ddTHH:mm:ss" |
|||
] |
|||
}, |
|||
"SkyWalking": { |
|||
"Enable": false |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Information", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Information" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Async", |
|||
"Args": { |
|||
"configure": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
<IsPackable>false</IsPackable> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.LocalizationService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Extensions.Logging" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" /> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.LocalizationService.EntityFrameworkCore\LINGYUN.Abp.MicroService.LocalizationService.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Update="appsettings.json"> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
</None> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,48 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
public class LocalizationServiceDbMigratorHostedService : IHostedService |
|||
{ |
|||
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public LocalizationServiceDbMigratorHostedService( |
|||
IHostApplicationLifetime hostApplicationLifetime, |
|||
IConfiguration configuration) |
|||
{ |
|||
_hostApplicationLifetime = hostApplicationLifetime; |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using var application = await AbpApplicationFactory |
|||
.CreateAsync<LocalizationServiceDbMigratorModule>(options => |
|||
{ |
|||
options.Services.ReplaceConfiguration(_configuration); |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
options.AddDataMigrationEnvironment(); |
|||
}); |
|||
await application.InitializeAsync(); |
|||
|
|||
await application |
|||
.ServiceProvider |
|||
.GetRequiredService<LocalizationServiceDbMigrationService>() |
|||
.CheckAndApplyDatabaseMigrationsAsync(); |
|||
|
|||
await application.ShutdownAsync(); |
|||
|
|||
_hostApplicationLifetime.StopApplication(); |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(LocalizationServiceMigrationsEntityFrameworkCoreModule) |
|||
)] |
|||
public class LocalizationServiceDbMigratorModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using LINGYUN.Abp.MicroService.LocalizationService; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
var defaultOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"; |
|||
|
|||
Log.Logger = new LoggerConfiguration() |
|||
.MinimumLevel.Information() |
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|||
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
|||
#if DEBUG
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.LocalizationService", LogEventLevel.Debug) |
|||
#else
|
|||
.MinimumLevel.Override("LINGYUN.Abp.MicroService.LocalizationService", LogEventLevel.Information) |
|||
#endif
|
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(x => x.Console(outputTemplate: defaultOutputTemplate)) |
|||
.WriteTo.Async(x => x.File("Logs/migrations.txt", outputTemplate: defaultOutputTemplate)) |
|||
.CreateLogger(); |
|||
|
|||
try |
|||
{ |
|||
var builder = Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<LocalizationServiceDbMigratorHostedService>(); |
|||
}); |
|||
await builder.RunConsoleAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
} |
|||
finally |
|||
{ |
|||
await Log.CloseAndFlushAsync(); |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Host=127.0.0.1;Database=abp;Username=postgres;Password=123456" |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<IsPackable>false</IsPackable> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.LocalizationService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,25 @@ |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EntityFrameworkCore.Migrations; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
public class LocalizationServiceDbMigrationEventHandler : EfCoreDatabaseMigrationEventHandlerBase<LocalizationServiceMigrationsDbContext> |
|||
{ |
|||
public LocalizationServiceDbMigrationEventHandler( |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
ITenantStore tenantStore, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<LocalizationServiceMigrationsDbContext>(), |
|||
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,26 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using Microsoft.Extensions.Logging; |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
public class LocalizationServiceDbMigrationService : EfCoreRuntimeDbMigratorBase<LocalizationServiceMigrationsDbContext>, ITransientDependency |
|||
{ |
|||
public LocalizationServiceDbMigrationService( |
|||
ICurrentTenant currentTenant, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
IServiceProvider serviceProvider, |
|||
IAbpDistributedLock abpDistributedLock, |
|||
IDistributedEventBus distributedEventBus, |
|||
ILoggerFactory loggerFactory) |
|||
: base( |
|||
ConnectionStringNameAttribute.GetConnStringName<LocalizationServiceMigrationsDbContext>(), |
|||
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory) |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using LINGYUN.Abp.LocalizationManagement; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
|
|||
[ConnectionStringName("Default")] |
|||
public class LocalizationServiceMigrationsDbContext : |
|||
AbpDbContext<LocalizationServiceMigrationsDbContext>, |
|||
ILocalizationDbContext |
|||
{ |
|||
public DbSet<Resource> Resources { get; set; } |
|||
|
|||
public DbSet<Language> Languages { get; set; } |
|||
|
|||
public DbSet<Text> Texts { get; set; } |
|||
|
|||
public LocalizationServiceMigrationsDbContext(DbContextOptions<LocalizationServiceMigrationsDbContext> options) |
|||
: base(options) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureLocalization(); |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using LINGYUN.Abp.MicroService.LocalizationService; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.IO; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.PlatformService; |
|||
public class LocalizationServiceMigrationsDbContextFactory : IDesignTimeDbContextFactory<LocalizationServiceMigrationsDbContext> |
|||
{ |
|||
public LocalizationServiceMigrationsDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
var connectionString = configuration.GetConnectionString("Default"); |
|||
|
|||
var builder = new DbContextOptionsBuilder<LocalizationServiceMigrationsDbContext>() |
|||
.UseNpgsql(connectionString); |
|||
|
|||
return new LocalizationServiceMigrationsDbContext(builder!.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../LINGYUN.Abp.MicroService.LocalizationService.DbMigrator/")) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,41 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.PostgreSql; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSaasEntityFrameworkCoreModule), |
|||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
|||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
|||
typeof(AbpEntityFrameworkCorePostgreSqlModule), |
|||
typeof(AbpDataDbMigratorModule) |
|||
)] |
|||
public class LocalizationServiceMigrationsEntityFrameworkCoreModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
|||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAbpDbContext<LocalizationServiceMigrationsDbContext>(); |
|||
|
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
options.UseNpgsql(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using LINGYUN.Abp.MicroService.LocalizationService; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService.Migrations |
|||
{ |
|||
[DbContext(typeof(LocalizationServiceMigrationsDbContext))] |
|||
[Migration("20260105085421_Initial_Localization_Service")] |
|||
partial class Initial_Localization_Service |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql) |
|||
.HasAnnotation("ProductVersion", "9.0.5") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|||
|
|||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("CultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("CultureName"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<bool>("Enable") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("boolean") |
|||
.HasDefaultValue(true); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("TwoLetterISOLanguageName") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("character varying(30)") |
|||
.HasColumnName("TwoLetterISOLanguageName"); |
|||
|
|||
b.Property<string>("UiCultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("UiCultureName"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("CultureName"); |
|||
|
|||
b.ToTable("AbpLocalizationLanguages", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("DefaultCultureName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DefaultCultureName"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("Description"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<bool>("Enable") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("boolean") |
|||
.HasDefaultValue(true); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(50) |
|||
.HasColumnType("character varying(50)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name"); |
|||
|
|||
b.ToTable("AbpLocalizationResources", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => |
|||
{ |
|||
b.Property<int>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("integer"); |
|||
|
|||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|||
|
|||
b.Property<string>("CultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("CultureName"); |
|||
|
|||
b.Property<string>("Key") |
|||
.IsRequired() |
|||
.HasMaxLength(512) |
|||
.HasColumnType("character varying(512)") |
|||
.HasColumnName("Key"); |
|||
|
|||
b.Property<string>("ResourceName") |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<string>("Value") |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("character varying(2048)") |
|||
.HasColumnName("Value"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Key"); |
|||
|
|||
b.ToTable("AbpLocalizationTexts", (string)null); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class Initial_Localization_Service : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpLocalizationLanguages", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Enable = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true), |
|||
CultureName = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false), |
|||
UiCultureName = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
|||
TwoLetterISOLanguageName = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpLocalizationLanguages", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpLocalizationResources", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
Enable = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true), |
|||
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false), |
|||
DisplayName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
Description = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
DefaultCultureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uuid", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpLocalizationResources", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpLocalizationTexts", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<int>(type: "integer", nullable: false) |
|||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
|||
CultureName = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false), |
|||
Key = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false), |
|||
Value = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true), |
|||
ResourceName = table.Column<string>(type: "text", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpLocalizationTexts", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpLocalizationLanguages_CultureName", |
|||
table: "AbpLocalizationLanguages", |
|||
column: "CultureName"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpLocalizationResources_Name", |
|||
table: "AbpLocalizationResources", |
|||
column: "Name"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpLocalizationTexts_Key", |
|||
table: "AbpLocalizationTexts", |
|||
column: "Key"); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpLocalizationLanguages"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpLocalizationResources"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpLocalizationTexts"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,174 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using LINGYUN.Abp.MicroService.LocalizationService; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace LINGYUN.Abp.MicroService.LocalizationService.Migrations |
|||
{ |
|||
[DbContext(typeof(LocalizationServiceMigrationsDbContext))] |
|||
partial class LocalizationServiceMigrationsDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql) |
|||
.HasAnnotation("ProductVersion", "9.0.5") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|||
|
|||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("CultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("CultureName"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.IsRequired() |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<bool>("Enable") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("boolean") |
|||
.HasDefaultValue(true); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("TwoLetterISOLanguageName") |
|||
.HasMaxLength(30) |
|||
.HasColumnType("character varying(30)") |
|||
.HasColumnName("TwoLetterISOLanguageName"); |
|||
|
|||
b.Property<string>("UiCultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("UiCultureName"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("CultureName"); |
|||
|
|||
b.ToTable("AbpLocalizationLanguages", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("DefaultCultureName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DefaultCultureName"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("Description"); |
|||
|
|||
b.Property<string>("DisplayName") |
|||
.HasMaxLength(64) |
|||
.HasColumnType("character varying(64)") |
|||
.HasColumnName("DisplayName"); |
|||
|
|||
b.Property<bool>("Enable") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("boolean") |
|||
.HasDefaultValue(true); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("timestamp with time zone") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("uuid") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(50) |
|||
.HasColumnType("character varying(50)") |
|||
.HasColumnName("Name"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Name"); |
|||
|
|||
b.ToTable("AbpLocalizationResources", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => |
|||
{ |
|||
b.Property<int>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("integer"); |
|||
|
|||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); |
|||
|
|||
b.Property<string>("CultureName") |
|||
.IsRequired() |
|||
.HasMaxLength(20) |
|||
.HasColumnType("character varying(20)") |
|||
.HasColumnName("CultureName"); |
|||
|
|||
b.Property<string>("Key") |
|||
.IsRequired() |
|||
.HasMaxLength(512) |
|||
.HasColumnType("character varying(512)") |
|||
.HasColumnName("Key"); |
|||
|
|||
b.Property<string>("ResourceName") |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<string>("Value") |
|||
.HasMaxLength(2048) |
|||
.HasColumnType("character varying(2048)") |
|||
.HasColumnName("Value"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("Key"); |
|||
|
|||
b.ToTable("AbpLocalizationTexts", (string)null); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="..\..\..\common.secrets.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net9.0</TargetFramework> |
|||
<RootNamespace>LINGYUN.Abp.MicroService.LocalizationService</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AgileConfig.Client" /> |
|||
<PackageReference Include="DotNetCore.CAP.Dashboard" /> |
|||
<PackageReference Include="DotNetCore.CAP.PostgreSql" /> |
|||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" /> |
|||
<PackageReference Include="DistributedLock.Redis" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> |
|||
<PackageReference Include="Serilog.AspNetCore" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> |
|||
<PackageReference Include="Serilog.Sinks.File" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" /> |
|||
<PackageReference Include="Volo.Abp.Http.Client" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\framework\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" /> |
|||
<ProjectReference Include="..\..\framework\authorization\LINGYUN.Abp.Authorization.OrganizationUnits\LINGYUN.Abp.Authorization.OrganizationUnits.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" /> |
|||
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.ExceptionHandling.Emailing\LINGYUN.Abp.ExceptionHandling.Emailing.csproj" /> |
|||
<ProjectReference Include="..\..\framework\localization\LINGYUN.Abp.Localization.CultureMap\LINGYUN.Abp.Localization.CultureMap.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.Application\LINGYUN.Abp.Serilog.Enrichers.Application.csproj" /> |
|||
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" /> |
|||
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" /> |
|||
<ProjectReference Include="..\..\framework\security\LINGYUN.Abp.Claims.Mapping\LINGYUN.Abp.Claims.Mapping.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.LocalizationService.EntityFrameworkCore\LINGYUN.Abp.MicroService.LocalizationService.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Session.AspNetCore\LINGYUN.Abp.Identity.Session.AspNetCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.Application\LINGYUN.Abp.LocalizationManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.HttpApi\LINGYUN.Abp.LocalizationManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Emailing.Platform\LINGYUN.Abp.Emailing.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.Sms.Platform\LINGYUN.Abp.Sms.Platform.csproj" /> |
|||
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.MicroService.ServiceDefaults\LINGYUN.Abp.MicroService.ServiceDefaults.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue