diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json
new file mode 100644
index 000000000..f8b488856
--- /dev/null
+++ b/.vs/ProjectSettings.json
@@ -0,0 +1,3 @@
+{
+ "CurrentProjectSetting": null
+}
\ No newline at end of file
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
new file mode 100644
index 000000000..f8debc5aa
Binary files /dev/null and b/.vs/slnx.sqlite differ
diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln
index e8291a295..d3f477df8 100644
--- a/aspnet-core/LINGYUN.MicroService.All.sln
+++ b/aspnet-core/LINGYUN.MicroService.All.sln
@@ -265,9 +265,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cloud-aliyun", "cloud-aliyu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cloud-tencent", "cloud-tencent", "{3B96F4D8-4993-419B-BCEB-AFE4ED39449F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Aliyun", "modules\cloud-aliyun\LINGYUN.Abp.Aliyun\LINGYUN.Abp.Aliyun.csproj", "{FCFAF1AF-B3F6-45F3-85AB-8249EB8432CC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Aliyun", "modules\cloud-aliyun\LINGYUN.Abp.Aliyun\LINGYUN.Abp.Aliyun.csproj", "{FCFAF1AF-B3F6-45F3-85AB-8249EB8432CC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Tencent", "modules\cloud-tencent\LINGYUN.Abp.Tencent\LINGYUN.Abp.Tencent.csproj", "{97B4A37E-B93E-48C9-95D5-689CB9495D8B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Tencent", "modules\cloud-tencent\LINGYUN.Abp.Tencent\LINGYUN.Abp.Tencent.csproj", "{97B4A37E-B93E-48C9-95D5-689CB9495D8B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Sms", "modules\common\LINGYUN.Abp.Notifications.Sms\LINGYUN.Abp.Notifications.Sms.csproj", "{8C3312E7-F51E-4780-A893-CE0E0B80B579}"
EndProject
diff --git a/aspnet-core/LINGYUN.MicroService.ApiGateway.sln b/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
index 68b066655..82cf7d3ce 100644
--- a/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
+++ b/aspnet-core/LINGYUN.MicroService.ApiGateway.sln
@@ -31,6 +31,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{D6629D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.EventBus.CAP", "modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj", "{1DA1835B-9EA4-4095-A8CF-10E2778206D3}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.ApiGateWay.Admin.Domain.Shared", "modules\apigateway\LINGYUN.ApiGateWay.Admin.Domain.Shared\LINGYUN.ApiGateWay.Admin.Domain.Shared.csproj", "{1CC3B44E-213A-4853-8128-9935F2A4C5D4}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.ApiGateWay.Admin.Domain", "modules\apigateway\LINGYUN.ApiGateWay.Admin.Domain\LINGYUN.ApiGateWay.Admin.Domain.csproj", "{1D548FA0-2A8F-455F-8814-F152751FB738}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -77,6 +81,14 @@ Global
{1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DA1835B-9EA4-4095-A8CF-10E2778206D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1CC3B44E-213A-4853-8128-9935F2A4C5D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1CC3B44E-213A-4853-8128-9935F2A4C5D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1CC3B44E-213A-4853-8128-9935F2A4C5D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1CC3B44E-213A-4853-8128-9935F2A4C5D4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1D548FA0-2A8F-455F-8814-F152751FB738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1D548FA0-2A8F-455F-8814-F152751FB738}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1D548FA0-2A8F-455F-8814-F152751FB738}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1D548FA0-2A8F-455F-8814-F152751FB738}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -94,6 +106,8 @@ Global
{4757C7D9-6AE9-477D-9829-55D9906AC3E6} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
{D6629DD3-BA0F-44B5-A97F-3B992ECAB85D} = {630FB448-8C5C-438F-930D-B0209407DE6A}
{1DA1835B-9EA4-4095-A8CF-10E2778206D3} = {D6629DD3-BA0F-44B5-A97F-3B992ECAB85D}
+ {1CC3B44E-213A-4853-8128-9935F2A4C5D4} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
+ {1D548FA0-2A8F-455F-8814-F152751FB738} = {AD93DD04-989C-40BE-A3F4-25DABF290423}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B327C65A-BD15-480D-825E-9D5A870C521A}
diff --git a/aspnet-core/configuration/account/AuthServer.Host/appsettings.Development.json b/aspnet-core/configuration/account/AuthServer.Host/appsettings.Development.json
index 171925d67..de75a6e93 100644
--- a/aspnet-core/configuration/account/AuthServer.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/account/AuthServer.Host/appsettings.Development.json
@@ -1,7 +1,14 @@
{
"App": {
+ "TrackingEntitiesChanged": true,
"SelfUrl": "http://localhost:44385/",
- "CorsOrigins": "http://localhost:4200,http://localhost:9528,http://127.0.0.1:63898"
+ "CorsOrigins": "http://localhost:4200,http://localhost:9528,http://127.0.0.1:63898",
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
},
"AppSelfUrl": "http://localhost:44385/",
"ConnectionStrings": {
diff --git a/aspnet-core/configuration/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/appsettings.Development.json b/aspnet-core/configuration/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/appsettings.Development.json
index 39129c934..275a624bc 100644
--- a/aspnet-core/configuration/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/appsettings.Development.json
@@ -1,4 +1,14 @@
{
+ "App": {
+ "TrackingEntitiesChanged": true,
+ "SelfUrl": "http://localhost:44385/",
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
+ },
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456",
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456",
@@ -24,7 +34,7 @@
"Aliyun": {
"Auth": {
"AccessKeyId": "你自己的阿里云Sms服务Key",
- "AccessKeySecret": "你自己的阿里云Sms服务KeySecret",
+ "AccessKeySecret": "你自己的阿里云Sms服务KeySecret"
},
"Sms": {
"RegionId": "cn-hangzhou",
diff --git a/aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json b/aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json
index bffda7073..169d08a49 100644
--- a/aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json
@@ -1,4 +1,14 @@
{
+ "App": {
+ "TrackingEntitiesChanged": true,
+ "SelfUrl": "http://localhost:44385/",
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
+ },
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=ApiGateway;User Id=root;Password=123456",
"ApiGateway": "Server=127.0.0.1;Database=ApiGateway;User Id=root;Password=123456",
diff --git a/aspnet-core/configuration/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/appsettings.Development.json b/aspnet-core/configuration/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/appsettings.Development.json
index 7b87d8c43..6b860626b 100644
--- a/aspnet-core/configuration/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/appsettings.Development.json
@@ -1,4 +1,13 @@
{
+ "App": {
+ "TrackingEntitiesChanged": true,
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
+ },
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456",
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer;User Id=root;Password=123456",
@@ -30,7 +39,7 @@
"Aliyun": {
"Auth": {
"AccessKeyId": "你自己的阿里云Sms服务Key",
- "AccessKeySecret": "你自己的阿里云Sms服务KeySecret",
+ "AccessKeySecret": "你自己的阿里云Sms服务KeySecret"
},
"Sms": {
"RegionId": "cn-hangzhou",
diff --git a/aspnet-core/configuration/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json b/aspnet-core/configuration/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json
index 2501d64b5..e910c3b27 100644
--- a/aspnet-core/configuration/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/messages/LINGYUN.Abp.MessageService.HttpApi.Host/appsettings.Development.json
@@ -1,6 +1,12 @@
{
"App": {
- "CorsOrigins": "http://localhost:9527,http://127.0.0.1:30000"
+ "CorsOrigins": "http://localhost:9527,http://127.0.0.1:30000",
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Messages;User Id=root;Password=123456",
diff --git a/aspnet-core/configuration/platform/LINGYUN.Platform.HttpApi.Host/appsettings.Development.json b/aspnet-core/configuration/platform/LINGYUN.Platform.HttpApi.Host/appsettings.Development.json
index 1df50d6b4..ef05ee973 100644
--- a/aspnet-core/configuration/platform/LINGYUN.Platform.HttpApi.Host/appsettings.Development.json
+++ b/aspnet-core/configuration/platform/LINGYUN.Platform.HttpApi.Host/appsettings.Development.json
@@ -1,4 +1,13 @@
{
+ "App": {
+ "CorsOrigins": "http://localhost:9527,http://127.0.0.1:30000",
+ "Forwarded": {
+ "ForwardedHeaders": 5,
+ "KnownProxies": [
+ "127.0.0.1"
+ ]
+ }
+ },
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform;User Id=colin;Password=123456",
"AppPlatform": "Server=127.0.0.1;Database=Platform;User Id=colin;Password=123456",
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN.ApiGateWay.Admin.Domain.Shared.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN.ApiGateWay.Admin.Domain.Shared.csproj
new file mode 100644
index 000000000..7ceb12aac
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN.ApiGateWay.Admin.Domain.Shared.csproj
@@ -0,0 +1,26 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainSharedModule.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainSharedModule.cs
new file mode 100644
index 000000000..4d63fbcee
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainSharedModule.cs
@@ -0,0 +1,32 @@
+using LINGYUN.ApiGateWay.Admin.Localization;
+using Volo.Abp.Localization;
+using Volo.Abp.Localization.ExceptionHandling;
+using Volo.Abp.Modularity;
+using Volo.Abp.VirtualFileSystem;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ [DependsOn(typeof(AbpLocalizationModule))]
+ public class ApiGateWayAdminDomainSharedModule : AbpModule
+ {
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.FileSets.AddEmbedded();
+ });
+
+ Configure(options =>
+ {
+ options.Resources
+ .Add("zh-Hans")
+ .AddVirtualJson("/LINGYUN/ApiGateWay/Admin/Localization/Resources");
+ });
+
+ Configure(options =>
+ {
+ options.MapCodeNamespace("ApiGateWayAdmin", typeof(ApiGateWayAdminResource));
+ });
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/HostAndPortConsts.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/HostAndPortConsts.cs
new file mode 100644
index 000000000..3dee1c02d
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/HostAndPortConsts.cs
@@ -0,0 +1,8 @@
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class HostAndPortConsts
+ {
+ // 计算机名最大长度
+ public const int MaxHostLength = 255;
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandlerConsts.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandlerConsts.cs
new file mode 100644
index 000000000..9b710ade9
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandlerConsts.cs
@@ -0,0 +1,7 @@
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class HttpDelegatingHandlerConsts
+ {
+ public const int MaxNameLength = 256;
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/ApiGateWayAdminResource.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/ApiGateWayAdminResource.cs
new file mode 100644
index 000000000..3293ea60e
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/ApiGateWayAdminResource.cs
@@ -0,0 +1,10 @@
+using Volo.Abp.Localization;
+
+namespace LINGYUN.ApiGateWay.Admin.Localization
+{
+ [LocalizationResourceName("ApiGatewayAdmin")]
+ public class ApiGateWayAdminResource
+ {
+
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/en.json b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/en.json
new file mode 100644
index 000000000..a9c8dcc3f
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/en.json
@@ -0,0 +1,5 @@
+{
+ "culture": "en",
+ "texts": {
+ }
+}
\ No newline at end of file
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/zh-Hans.json b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/zh-Hans.json
new file mode 100644
index 000000000..50324cb8c
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/Localization/Resources/zh-Hans.json
@@ -0,0 +1,6 @@
+{
+ "culture": "zh-Hans",
+ "texts": {
+
+ }
+}
\ No newline at end of file
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/RouteGroupAppKey.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/RouteGroupAppKey.cs
new file mode 100644
index 000000000..24dced636
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain.Shared/LINGYUN/ApiGateWay/Admin/RouteGroupAppKey.cs
@@ -0,0 +1,13 @@
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class RouteGroupAppKey
+ {
+ public string AppId { get; }
+ public string AppName { get; }
+ public RouteGroupAppKey(string appId, string appName)
+ {
+ AppId = appId;
+ AppName = appName;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN.ApiGateWay.Admin.Domain.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN.ApiGateWay.Admin.Domain.csproj
new file mode 100644
index 000000000..dfb938689
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN.ApiGateWay.Admin.Domain.csproj
@@ -0,0 +1,17 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainModule.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainModule.cs
new file mode 100644
index 000000000..a0f73e2a7
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/ApiGateWayAdminDomainModule.cs
@@ -0,0 +1,12 @@
+using Volo.Abp.Domain;
+using Volo.Abp.Modularity;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ [DependsOn(
+ typeof(ApiGateWayAdminDomainSharedModule),
+ typeof(AbpDddDomainModule))]
+ public class ApiGateWayAdminDomainModule : AbpModule
+ {
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Globals/Global.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Globals/Global.cs
new file mode 100644
index 000000000..c317fba3e
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Globals/Global.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Volo.Abp.Domain.Entities.Auditing;
+
+namespace LINGYUN.ApiGateWay.Admin.Globals
+{
+ public class Global : FullAuditedAggregateRoot
+ {
+
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/HostAndPort.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/HostAndPort.cs
new file mode 100644
index 000000000..883643b3d
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/HostAndPort.cs
@@ -0,0 +1,62 @@
+using JetBrains.Annotations;
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class HostAndPort : Entity
+ {
+ public virtual string Host { get; protected set; }
+ public virtual int? Port { get; protected set; }
+ protected HostAndPort()
+ {
+
+ }
+
+ public HostAndPort(Guid id, [NotNull] string host, int? port = null)
+ {
+ Id = id;
+ BindHost(host, port);
+ }
+
+ public void BindHost([NotNull] string host, int? port = null)
+ {
+ Check.NotNullOrWhiteSpace(host, nameof(host), HostAndPortConsts.MaxHostLength);
+ Host = host;
+ Port = port;
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Host.IsNullOrWhiteSpace())
+ {
+ if (Port.HasValue)
+ {
+ return Host.GetHashCode() & Port.Value;
+ }
+ return Host.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Host.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is HostAndPort hostAndPort)
+ {
+ if (Port.HasValue)
+ {
+ return hostAndPort.Host.Equals(Host) &&
+ Port.Equals(hostAndPort.Port);
+ }
+ return hostAndPort.Host.Equals(Host);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/DownstreamHttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/DownstreamHttpMethod.cs
new file mode 100644
index 000000000..480f50e03
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/DownstreamHttpMethod.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class DownstreamHttpMethod : HttpMethod
+ {
+ public DownstreamHttpMethod(Guid id, string method)
+ : base(id, method)
+ {
+
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandler.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandler.cs
new file mode 100644
index 000000000..d7cc305db
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpDelegatingHandler.cs
@@ -0,0 +1,45 @@
+using JetBrains.Annotations;
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class HttpDelegatingHandler : Entity
+ {
+ public virtual string Name { get; protected set; }
+ protected HttpDelegatingHandler()
+ {
+
+ }
+
+ public HttpDelegatingHandler(Guid id, [NotNull] string name)
+ {
+ Id = id;
+ Name = Check.NotNullOrWhiteSpace(name, nameof(name), HttpDelegatingHandlerConsts.MaxNameLength);
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Name.IsNullOrWhiteSpace())
+ {
+ return Name.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Name.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is HttpDelegatingHandler handler)
+ {
+ return Name.Equals(handler.Name, StringComparison.CurrentCultureIgnoreCase);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHandler.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHandler.cs
new file mode 100644
index 000000000..80802452d
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHandler.cs
@@ -0,0 +1,43 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class HttpHandler : Entity
+ {
+ ///
+ /// 每台服务器最大连接数
+ ///
+ public virtual int? MaxConnectionsPerServer { get; protected set; }
+ ///
+ /// 允许自动重定向
+ ///
+ public virtual bool AllowAutoRedirect { get; set; }
+ ///
+ /// 使用Cookie容器
+ ///
+ public virtual bool UseCookieContainer { get; set; }
+ ///
+ /// 启用跟踪
+ ///
+ public virtual bool UseTracing { get; set; }
+ ///
+ /// 启用代理
+ ///
+ public virtual bool UseProxy { get; set; }
+ protected HttpHandler()
+ {
+
+ }
+
+ public HttpHandler(Guid id)
+ {
+ Id = id;
+ }
+
+ public void ChangeMaxConnection(int? maxConnection = 1000)
+ {
+ MaxConnectionsPerServer = maxConnection;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHeader.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHeader.cs
new file mode 100644
index 000000000..b0407ccdf
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpHeader.cs
@@ -0,0 +1,51 @@
+using JetBrains.Annotations;
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public abstract class HttpHeader : Entity
+ {
+ public virtual string Key { get; protected set; }
+ public virtual string Value { get; protected set; }
+
+ protected HttpHeader()
+ {
+
+ }
+
+ protected HttpHeader(Guid id, [NotNull] string key, [NotNull] string value)
+ {
+ Id = id;
+ Key = Check.NotNullOrWhiteSpace(key, nameof(key));
+ Value = Check.NotNullOrWhiteSpace(value, nameof(value));
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Key.IsNullOrWhiteSpace() &&
+ !Value.IsNullOrWhiteSpace())
+ {
+ return Key.GetHashCode() & Value.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Key.IsNullOrWhiteSpace() ||
+ Value.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is HttpHeader httpHeader)
+ {
+ return httpHeader.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase) &&
+ httpHeader.Value.Equals(Value, StringComparison.CurrentCultureIgnoreCase);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpMethod.cs
new file mode 100644
index 000000000..9a5acaadf
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpMethod.cs
@@ -0,0 +1,45 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public abstract class HttpMethod : Entity
+ {
+ ///
+ /// Http调用方法
+ ///
+ public virtual string Method { get; protected set; }
+ protected HttpMethod()
+ {
+
+ }
+ protected HttpMethod(Guid id, string method)
+ {
+ Id = id;
+ Method = method;
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Method.IsNullOrWhiteSpace())
+ {
+ return Method.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Method.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is HttpMethod httpMethod)
+ {
+ return httpMethod.Method.Equals(Method);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpQuery.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpQuery.cs
new file mode 100644
index 000000000..91a344383
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/HttpQuery.cs
@@ -0,0 +1,51 @@
+using JetBrains.Annotations;
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class HttpQuery : Entity
+ {
+ public virtual string Key { get; protected set; }
+ public virtual string Value { get; protected set; }
+
+ protected HttpQuery()
+ {
+
+ }
+
+ protected HttpQuery(Guid id, [NotNull] string key, [NotNull] string value)
+ {
+ Id = id;
+ Key = Check.NotNullOrWhiteSpace(key, nameof(key));
+ Value = Check.NotNullOrWhiteSpace(value, nameof(value));
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Key.IsNullOrWhiteSpace() &&
+ !Value.IsNullOrWhiteSpace())
+ {
+ return Key.GetHashCode() & Value.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Key.IsNullOrWhiteSpace() ||
+ Value.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is HttpQuery httpQuery)
+ {
+ return Key.Equals(httpQuery.Key, StringComparison.CurrentCultureIgnoreCase) &&
+ Value.Equals(httpQuery.Value, StringComparison.CurrentCultureIgnoreCase);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/UpstreamHttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/UpstreamHttpMethod.cs
new file mode 100644
index 000000000..d9ffe0dae
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Http/UpstreamHttpMethod.cs
@@ -0,0 +1,13 @@
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Http
+{
+ public class UpstreamHttpMethod : HttpMethod
+ {
+ public UpstreamHttpMethod(Guid id, string method)
+ : base(id, method)
+ {
+
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/LoadBalancer.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/LoadBalancer.cs
new file mode 100644
index 000000000..bab6275ef
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/LoadBalancer.cs
@@ -0,0 +1,37 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class LoadBalancer : Entity
+ {
+ ///
+ /// 负载均衡类型
+ ///
+ public virtual string Type { get; private set; }
+ ///
+ /// 用于Cookie会话密钥
+ ///
+ public virtual string Key { get; private set; }
+ ///
+ /// 会话阻断时间
+ ///
+ public virtual int? Expiry { get; private set; }
+ protected LoadBalancer()
+ {
+
+ }
+ public LoadBalancer(Guid id, string type, string key, int? expiry = null)
+ {
+ Id = id;
+ ApplyPolicy(type, key, expiry);
+ }
+
+ public void ApplyPolicy(string type, string key, int? expiry = null)
+ {
+ Type = type;
+ Key = key;
+ Expiry = expiry;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/QoS.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/QoS.cs
new file mode 100644
index 000000000..1fac583e0
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/QoS.cs
@@ -0,0 +1,32 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class QoS : Entity
+ {
+ public virtual int? ExceptionsAllowedBeforeBreaking { get; private set; }
+
+ public virtual int? DurationOfBreak { get; private set; }
+
+ public virtual int? TimeoutValue { get; private set; }
+
+ protected QoS()
+ {
+
+ }
+
+ public QoS(Guid id, int? exceptionsAllowdBeforeBreaking = null, int? durationOfBreak = null, int? timeOut = null)
+ {
+ Id = id;
+ ApplyPolicy(exceptionsAllowdBeforeBreaking, durationOfBreak, timeOut);
+ }
+
+ public void ApplyPolicy(int? exceptionsAllowdBeforeBreaking = null, int? durationOfBreak = null, int? timeOut = null)
+ {
+ ExceptionsAllowedBeforeBreaking = exceptionsAllowdBeforeBreaking;
+ DurationOfBreak = durationOfBreak;
+ TimeoutValue = timeOut;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/RateLimitRule.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/RateLimitRule.cs
new file mode 100644
index 000000000..868301386
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/RateLimitRule.cs
@@ -0,0 +1,57 @@
+using LINGYUN.ApiGateWay.Admin.Security;
+using System;
+using System.Collections.Generic;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin
+{
+ public class RateLimitRule : Entity
+ {
+ ///
+ /// 客户端白名单列表,多个以分号分隔
+ ///
+ public virtual ICollection ClientWhiteList { get; private set; }
+ ///
+ /// 是否启用流量现值
+ ///
+ public virtual bool EnableRateLimiting { get; private set; }
+ ///
+ /// 限速时段
+ ///
+ public virtual string Period { get; private set; }
+ ///
+ /// 速率极限周期
+ ///
+ public virtual double? PeriodTimespan { get; private set; }
+ ///
+ /// 客户端在定义的时间内可以发出的最大请求数
+ ///
+ public virtual long? Limit { get; private set; }
+
+ protected RateLimitRule()
+ {
+ ClientWhiteList = new List();
+ }
+
+ public RateLimitRule(Guid id, string period = "", double? periodTimespan = null,
+ long? limit = null, bool enabled = true)
+ {
+ Id = id;
+ ChangeRateLimitState(enabled);
+ ApplyPolicy(period, periodTimespan, limit);
+ }
+
+ public void ChangeRateLimitState(bool enabled = true)
+ {
+ EnableRateLimiting = enabled;
+ }
+
+ public void ApplyPolicy(string period = "", double? periodTimespan = null,
+ long? limit = null)
+ {
+ Period = period;
+ PeriodTimespan = periodTimespan;
+ Limit = limit;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/Route.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/Route.cs
new file mode 100644
index 000000000..7bac3ce3e
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/Route.cs
@@ -0,0 +1,348 @@
+using LINGYUN.ApiGateWay.Admin.Security;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.Guids;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class Route : FullAuditedAggregateRoot
+ {
+ ///
+ /// 应用标识
+ ///
+ public virtual string AppId { get; protected set; }
+ ///
+ /// 路由名称
+ ///
+ public virtual string Name { get; protected set; }
+ ///
+ /// 请求标识
+ ///
+ public virtual string RequestIdKey { get; set; }
+ ///
+ /// 是否区分大小写
+ ///
+ public virtual bool RouteIsCaseSensitive { get; set; }
+ ///
+ /// 服务名称
+ ///
+ public virtual string ServiceName { get; protected set; }
+ ///
+ /// 服务命名空间
+ ///
+ public virtual string ServiceNamespace { get; protected set; }
+ ///
+ /// 下游协议
+ ///
+ public virtual string DownstreamScheme { get; set; }
+ ///
+ /// 下游路由路径
+ ///
+ public virtual string DownstreamPathTemplate { get; protected set; }
+ ///
+ /// 上游路由路径
+ ///
+ public virtual string UpstreamPathTemplate { get; protected set; }
+ ///
+ /// 变更下游路径
+ ///
+ public virtual string ChangeDownstreamPathTemplate { get; protected set; }
+ ///
+ /// 上游主机
+ ///
+ public virtual string UpstreamHost { get; set; }
+ ///
+ /// 聚合标识
+ ///
+ public virtual string Key { get; set; }
+ ///
+ /// 优先级
+ ///
+ public virtual int? Priority { get; set; }
+ ///
+ /// 超时时间
+ ///
+ public virtual int? Timeout { get; set; }
+ ///
+ /// 忽略SSL警告
+ ///
+ public virtual bool DangerousAcceptAnyServerCertificateValidator { get; set; }
+ ///
+ /// 下游版本号
+ ///
+ public virtual string DownstreamHttpVersion { get; set; }
+ ///
+ /// 下游Http方法列表
+ ///
+ public virtual ICollection UpstreamHttpMethods { get; protected set; }
+ ///
+ /// 上游Http方法列表
+ ///
+ public virtual ICollection DownstreamHttpMethods { get; protected set; }
+ ///
+ /// 添加请求头参数
+ ///
+ public virtual ICollection AddHeadersToRequest { get; protected set; }
+ ///
+ /// 下游请求头转换
+ ///
+ public virtual ICollection UpstreamHeaderTransform { get; protected set; }
+ ///
+ /// 上游请求头转换
+ ///
+ public virtual ICollection DownstreamHeaderTransform { get; protected set; }
+ ///
+ /// 请求声明转换
+ ///
+ public virtual ICollection AddClaimsToRequest { get; protected set; }
+ ///
+ /// 请求必须的声明
+ ///
+ public virtual ICollection RouteClaimsRequirement { get; protected set; }
+ ///
+ /// 用户声明到请求头转换
+ ///
+ public virtual ICollection AddQueriesToRequest { get; protected set; }
+ ///
+ /// 下游主机列表
+ ///
+ public virtual ICollection DownstreamHostAndPorts { get; protected set; }
+ ///
+ /// 授权处理器列表
+ ///
+ public virtual ICollection DelegatingHandlers { get; protected set; }
+ ///
+ /// Http选项
+ ///
+ public virtual RouteHttpHandler HttpHandler { get; protected set; }
+ ///
+ /// 授权
+ ///
+ public virtual RouteAuthentication Authentication { get; protected set; }
+ ///
+ /// 速率限制
+ ///
+ public virtual RouteRateLimitRule RouteRateLimitRule { get; protected set; }
+ ///
+ /// 负债均衡
+ ///
+ public virtual RouteLoadBalancer LoadBalancer { get; protected set; }
+ ///
+ /// 服务质量
+ ///
+ public virtual RouteQos QoS { get; protected set; }
+ ///
+ /// 文件缓存
+ ///
+ public virtual RouteCache Cache { get; protected set; }
+ ///
+ /// 安全策略
+ ///
+ public virtual RouteSecurity Security { get; protected set; }
+
+ protected Route()
+ {
+ UpstreamHttpMethods = new Collection();
+ DownstreamHttpMethods = new Collection();
+ AddHeadersToRequest = new Collection();
+ UpstreamHeaderTransform = new Collection();
+ DownstreamHeaderTransform = new Collection();
+ AddClaimsToRequest = new Collection();
+ RouteClaimsRequirement = new Collection();
+ AddQueriesToRequest = new Collection();
+ DownstreamHostAndPorts = new Collection();
+ DelegatingHandlers = new Collection();
+ }
+
+ public void AddDownstreamHttpMethod(IGuidGenerator generator, string method)
+ {
+ DownstreamHttpMethods.AddIfNotContains(new RouteDownstreamHttpMethod(Id, generator.Create(), method)); ;
+ }
+
+ public void RemoveDownstreamHttpMethod(string method)
+ {
+ DownstreamHttpMethods.RemoveAll(x => x.Method.Equals(method, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllDownstreamHttpMethod()
+ {
+ DownstreamHttpMethods.Clear();
+ }
+
+ public void AddUpstreamHttpMethod(IGuidGenerator generator, string method)
+ {
+ UpstreamHttpMethods.AddIfNotContains(new RouteUpstreamHttpMethod(Id, generator.Create(), method));
+ }
+
+ public void RemoveUpstreamHttpMethod(string method)
+ {
+ UpstreamHttpMethods.RemoveAll(x => x.Method.Equals(method, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllUpstreamHttpMethod()
+ {
+ UpstreamHttpMethods.Clear();
+ }
+
+ public void AddRequestHeader(IGuidGenerator generator, string key, string value)
+ {
+ AddHeadersToRequest.AddIfNotContains(new RouteAddRequestHttpHeader(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveRequestHeader(string key, string value)
+ {
+ AddHeadersToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllRequestHeader()
+ {
+ AddHeadersToRequest.Clear();
+ }
+
+ public void AddUpstreamHeaderTransform(IGuidGenerator generator, string key, string value)
+ {
+ UpstreamHeaderTransform.AddIfNotContains(new RouteUpstreamTransformHttpHeader(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveUpstreamHeaderTransform(string key, string value)
+ {
+ UpstreamHeaderTransform.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllUpstreamHeaderTransform()
+ {
+ UpstreamHeaderTransform.Clear();
+ }
+
+ public void AddDownstreamHeaderTransform(IGuidGenerator generator, string key, string value)
+ {
+ DownstreamHeaderTransform.AddIfNotContains(new RouteDownstreamTransformHttpHeader(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveDownstreamHeaderTransform(string key, string value)
+ {
+ DownstreamHeaderTransform.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllDownstreamHeaderTransform()
+ {
+ DownstreamHeaderTransform.Clear();
+ }
+
+ public void AddRequestClaim(IGuidGenerator generator, string key, string value)
+ {
+ AddClaimsToRequest.AddIfNotContains(new RouteAddToRequestClaim(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveRequestClaim(string key, string value)
+ {
+ AddClaimsToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllRequestClaim()
+ {
+ AddClaimsToRequest.Clear();
+ }
+
+ public void AddRequirementClaim(IGuidGenerator generator, string key, string value)
+ {
+ RouteClaimsRequirement.AddIfNotContains(new RouteRequirementClaim(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveRequirementClaim(string key, string value)
+ {
+ RouteClaimsRequirement.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllRequirementClaim()
+ {
+ RouteClaimsRequirement.Clear();
+ }
+
+ public void AddRequestQuery(IGuidGenerator generator, string key, string value)
+ {
+ AddQueriesToRequest.AddIfNotContains(new RouteAddToRequestHttpQuery(Id, generator.Create(), key, value));
+ }
+
+ public void RemoveRequestQuery(string key, string value)
+ {
+ AddQueriesToRequest.RemoveAll(x => x.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)
+ && x.Value.Equals(value, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllRequestQuery()
+ {
+ AddQueriesToRequest.Clear();
+ }
+
+ public void AddDownstreamHost(IGuidGenerator generator, string host, int? port)
+ {
+ DownstreamHostAndPorts.AddIfNotContains(new RouteDownstreamHostAndPort(Id, generator.Create(), host, port));
+ }
+
+ public void RemoveDownstreamHost(string host, int? port)
+ {
+ DownstreamHostAndPorts.RemoveAll(x => x.Host.Equals(host, StringComparison.CurrentCultureIgnoreCase)
+ && x.Port.Equals(port));
+ }
+
+ public void RemoveAllDownstreamHost()
+ {
+ DownstreamHostAndPorts.Clear();
+ }
+
+ public void AddDelegatingHandler(IGuidGenerator generator, string name)
+ {
+ DelegatingHandlers.AddIfNotContains(new RouteHttpDelegatingHandler(Id, generator.Create(), name));
+ }
+
+ public void RemoveDelegatingHandler(string name)
+ {
+ DelegatingHandlers.RemoveAll(x => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllDelegatingHandler()
+ {
+ DelegatingHandlers.Clear();
+ }
+
+ public void BindService(string serviceName, string @namespace)
+ {
+ ServiceName = serviceName;
+ ServiceNamespace = @namespace;
+ }
+
+ public void UseHttpHandler(IGuidGenerator generator, bool autoRedirect = false, bool useCookie = false,
+ bool useTracking = false, bool useProxy = false, int? maxConnection = 1000)
+ {
+ if (HttpHandler == null)
+ {
+ HttpHandler = new RouteHttpHandler(generator.Create(), Id);
+ }
+ HttpHandler.UseProxy = useProxy;
+ HttpHandler.UseTracing = useTracking;
+ HttpHandler.UseCookieContainer = useCookie;
+ HttpHandler.AllowAutoRedirect = autoRedirect;
+ HttpHandler.ChangeMaxConnection(maxConnection);
+ }
+
+ public void UseAuthentication(IGuidGenerator generator, string provider, IEnumerable allowScope)
+ {
+ if (Authentication == null)
+ {
+ Authentication = new RouteAuthentication(generator.Create(), Id, provider);
+ }
+ Authentication.AddScopes(allowScope);
+ }
+
+
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddRequestHttpHeader.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddRequestHttpHeader.cs
new file mode 100644
index 000000000..e6156a66a
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddRequestHttpHeader.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteAddRequestHttpHeader : HttpHeader
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteAddRequestHttpHeader()
+ {
+
+ }
+ public RouteAddRequestHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value)
+ : base(httpHeaderId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestClaim.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestClaim.cs
new file mode 100644
index 000000000..8748da69e
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestClaim.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Security;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteAddToRequestClaim : Claim
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteAddToRequestClaim()
+ {
+
+ }
+ public RouteAddToRequestClaim(Guid routeId, Guid claimId, string key, string value)
+ : base(claimId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestHttpQuery.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestHttpQuery.cs
new file mode 100644
index 000000000..b20073e45
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAddToRequestHttpQuery.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteAddToRequestHttpQuery : HttpQuery
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteAddToRequestHttpQuery()
+ {
+
+ }
+ public RouteAddToRequestHttpQuery(Guid routeId, Guid httpQueryId, string key, string value)
+ : base(httpQueryId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAllowedScope.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAllowedScope.cs
new file mode 100644
index 000000000..d2913ec8f
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAllowedScope.cs
@@ -0,0 +1,45 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteAllowedScope : Entity
+ {
+ public virtual string Scope { get; protected set; }
+ public virtual Guid AuthenticationId { get; protected set; }
+ public virtual RouteAuthentication Authentication { get; protected set; }
+ protected RouteAllowedScope()
+ {
+
+ }
+
+ public RouteAllowedScope(Guid authenticationId, string scope)
+ {
+ AuthenticationId = authenticationId;
+ Scope = scope;
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Scope.IsNullOrWhiteSpace())
+ {
+ return Scope.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Scope.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is RouteAllowedScope allowedScope)
+ {
+ return allowedScope.Scope.Equals(Scope);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAuthentication.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAuthentication.cs
new file mode 100644
index 000000000..c67ce7f3c
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteAuthentication.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteAuthentication : Entity
+ {
+ public virtual string AuthenticationProviderKey { get; private set; }
+ public virtual ICollection AllowedScopes { get; set; }
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteAuthentication()
+ {
+ AllowedScopes = new List();
+ }
+
+ public RouteAuthentication(Guid id, Guid routeId, string providerKey)
+ {
+ Id = id;
+ RouteId = routeId;
+ ChangeProvider(providerKey);
+ }
+
+ public void ChangeProvider(string providerKey)
+ {
+ AuthenticationProviderKey = providerKey;
+ }
+
+ public void AddScope(string scope)
+ {
+ AllowedScopes.AddIfNotContains(new RouteAllowedScope(Id, scope));
+ }
+
+ public void AddScopes(IEnumerable scope)
+ {
+ foreach(var scop in scope)
+ {
+ AddScope(scop);
+ }
+ }
+
+ public void RemoveScope(string scope)
+ {
+ AllowedScopes.RemoveAll(x => x.Scope.Equals(scope, StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ public void RemoveAllScope()
+ {
+ AllowedScopes.Clear();
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteCache.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteCache.cs
new file mode 100644
index 000000000..082176d35
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteCache.cs
@@ -0,0 +1,22 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteCache : Entity
+ {
+ public virtual int? TtlSeconds { get; private set; }
+ public virtual string Region { get; private set; }
+ public virtual Guid RouteId { get; private set; }
+ public virtual Route Route { get; private set; }
+ protected RouteCache()
+ {
+ }
+ public RouteCache(Guid routeId, string region = "", int? ttlSeconds = null)
+ {
+ RouteId = routeId;
+ Region = region;
+ TtlSeconds = ttlSeconds;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHostAndPort.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHostAndPort.cs
new file mode 100644
index 000000000..a34016a3f
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHostAndPort.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteDownstreamHostAndPort : HostAndPort
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteDownstreamHostAndPort()
+ {
+
+ }
+ public RouteDownstreamHostAndPort(Guid routeId, Guid hostId, string key, int? port)
+ : base(hostId, key, port)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHttpMethod.cs
new file mode 100644
index 000000000..c17811551
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamHttpMethod.cs
@@ -0,0 +1,21 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteDownstreamHttpMethod : HttpMethod
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteDownstreamHttpMethod()
+ {
+
+ }
+
+ public RouteDownstreamHttpMethod(Guid routeId, Guid httpMethodId, string method)
+ : base(httpMethodId, method)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamTransformHttpHeader.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamTransformHttpHeader.cs
new file mode 100644
index 000000000..288e50fb3
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteDownstreamTransformHttpHeader.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteDownstreamTransformHttpHeader : HttpHeader
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteDownstreamTransformHttpHeader()
+ {
+
+ }
+ public RouteDownstreamTransformHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value)
+ : base(httpHeaderId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpDelegatingHandler.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpDelegatingHandler.cs
new file mode 100644
index 000000000..473f9627f
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpDelegatingHandler.cs
@@ -0,0 +1,21 @@
+using JetBrains.Annotations;
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteHttpDelegatingHandler : HttpDelegatingHandler
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteHttpDelegatingHandler()
+ {
+
+ }
+ public RouteHttpDelegatingHandler(Guid routeId, Guid httpHandlerId, [NotNull] string name)
+ : base(httpHandlerId, name)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpHandler.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpHandler.cs
new file mode 100644
index 000000000..dc07f731c
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpHandler.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteHttpHandler : HttpHandler
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteHttpHandler()
+ {
+
+ }
+ public RouteHttpHandler(Guid id, Guid routeId)
+ {
+ Id = id;
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpMethod.cs
new file mode 100644
index 000000000..d4c099387
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteHttpMethod.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteHttpMethod
+ {
+
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteLoadBalancer.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteLoadBalancer.cs
new file mode 100644
index 000000000..65d38b155
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteLoadBalancer.cs
@@ -0,0 +1,23 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteLoadBalancer : Entity
+ {
+ public virtual Guid LoadBalancerId { get; private set; }
+ public virtual LoadBalancer LoadBalancer { get; private set; }
+ public virtual Guid RouteId { get; private set; }
+ public virtual Route Route { get; private set; }
+ protected RouteLoadBalancer()
+ {
+
+ }
+
+ public RouteLoadBalancer(Guid routeId, Guid loadBalancerId)
+ {
+ RouteId = routeId;
+ LoadBalancerId = loadBalancerId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteQos.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteQos.cs
new file mode 100644
index 000000000..c9a4ef23d
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteQos.cs
@@ -0,0 +1,22 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteQos : Entity
+ {
+ public virtual Guid QoSId { get; protected set; }
+ public virtual QoS QoS { get; protected set; }
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteQos()
+ {
+
+ }
+ public RouteQos(Guid routeId, Guid qosId)
+ {
+ RouteId = routeId;
+ QoSId = qosId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRateLimitRule.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRateLimitRule.cs
new file mode 100644
index 000000000..716076e14
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRateLimitRule.cs
@@ -0,0 +1,23 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteRateLimitRule : Entity
+ {
+ public virtual Guid RateLimitRuleId { get; protected set; }
+ public virtual RateLimitRule RateLimitRule { get; protected set; }
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteRateLimitRule()
+ {
+
+ }
+
+ public RouteRateLimitRule(Guid routeId, Guid rateLimitRuleId)
+ {
+ RouteId = routeId;
+ RateLimitRuleId = rateLimitRuleId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRequirementClaim.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRequirementClaim.cs
new file mode 100644
index 000000000..4168e78af
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteRequirementClaim.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Security;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteRequirementClaim : Claim
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteRequirementClaim()
+ {
+
+ }
+ public RouteRequirementClaim(Guid routeId, Guid claimId, string key, string value)
+ : base(claimId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamHttpMethod.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamHttpMethod.cs
new file mode 100644
index 000000000..654e3496b
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamHttpMethod.cs
@@ -0,0 +1,21 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteUpstreamHttpMethod : HttpMethod
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteUpstreamHttpMethod()
+ {
+
+ }
+
+ public RouteUpstreamHttpMethod(Guid routeId, Guid httpMethodId, string method)
+ : base(httpMethodId, method)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamTransformHttpHeader.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamTransformHttpHeader.cs
new file mode 100644
index 000000000..0c8bf5573
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Routes/RouteUpstreamTransformHttpHeader.cs
@@ -0,0 +1,20 @@
+using LINGYUN.ApiGateWay.Admin.Http;
+using System;
+
+namespace LINGYUN.ApiGateWay.Admin.Routes
+{
+ public class RouteUpstreamTransformHttpHeader : HttpHeader
+ {
+ public virtual Guid RouteId { get; protected set; }
+ public virtual Route Route { get; protected set; }
+ protected RouteUpstreamTransformHttpHeader()
+ {
+
+ }
+ public RouteUpstreamTransformHttpHeader(Guid routeId, Guid httpHeaderId, string key, string value)
+ : base(httpHeaderId, key, value)
+ {
+ RouteId = routeId;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/Claim.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/Claim.cs
new file mode 100644
index 000000000..e2667027c
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/Claim.cs
@@ -0,0 +1,50 @@
+using JetBrains.Annotations;
+using System;
+using Volo.Abp;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Security
+{
+ public class Claim : Entity
+ {
+ public virtual string Key { get; protected set; }
+ public virtual string Value { get; protected set; }
+ protected Claim()
+ {
+
+ }
+
+ protected Claim(Guid id, [NotNull] string key, [NotNull] string value)
+ {
+ Id = id;
+ Key = Check.NotNullOrWhiteSpace(key, nameof(key));
+ Value = Check.NotNullOrWhiteSpace(value, nameof(value));
+ }
+
+ public override int GetHashCode()
+ {
+ if (!Key.IsNullOrWhiteSpace() &&
+ !Value.IsNullOrWhiteSpace())
+ {
+ return Key.GetHashCode() & Value.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Key.IsNullOrWhiteSpace() ||
+ Value.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is Claim claim)
+ {
+ return claim.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase) &&
+ claim.Value.Equals(Value, StringComparison.CurrentCultureIgnoreCase);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteClientWhite.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteClientWhite.cs
new file mode 100644
index 000000000..fec50cf4f
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteClientWhite.cs
@@ -0,0 +1,34 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Security
+{
+ public class RouteClientWhite : Entity
+ {
+ public virtual string ClientId { get; private set; }
+ public virtual Guid RateLimitRuleId { get; private set; }
+ public virtual RateLimitRule RateLimitRule { get; private set; }
+ public override int GetHashCode()
+ {
+ if (!ClientId.IsNullOrWhiteSpace())
+ {
+ return ClientId.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ ClientId.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is RouteClientWhite clientWhite)
+ {
+ return clientWhite.ClientId.Equals(ClientId);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPBlock.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPBlock.cs
new file mode 100644
index 000000000..38f2fecae
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPBlock.cs
@@ -0,0 +1,40 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Security
+{
+ public class RouteIPBlock : Entity
+ {
+ public virtual string Address { get; private set; }
+ public virtual Guid SecurityId { get; private set; }
+ public virtual RouteSecurity Security { get; private set; }
+ protected RouteIPBlock() { }
+ public RouteIPBlock(Guid securityId, string address)
+ {
+ SecurityId = securityId;
+ Address = address;
+ }
+ public override int GetHashCode()
+ {
+ if (!Address.IsNullOrWhiteSpace())
+ {
+ return Address.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null ||
+ Address.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is RouteIPBlock iPBlock)
+ {
+ return iPBlock.Address.Equals(Address);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPWhite.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPWhite.cs
new file mode 100644
index 000000000..55e0a80d6
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteIPWhite.cs
@@ -0,0 +1,41 @@
+using System;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Security
+{
+ public class RouteIPWhite : Entity
+ {
+ public virtual string Address { get; private set; }
+ public virtual Guid SecurityId { get; private set; }
+ public virtual RouteSecurity Security { get; private set; }
+
+ protected RouteIPWhite() { }
+ public RouteIPWhite(Guid securityId, string address)
+ {
+ SecurityId = securityId;
+ Address = address;
+ }
+ public override int GetHashCode()
+ {
+ if (!Address.IsNullOrWhiteSpace())
+ {
+ return Address.GetHashCode();
+ }
+ return base.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if(obj == null ||
+ Address.IsNullOrWhiteSpace())
+ {
+ return false;
+ }
+ if (obj is RouteIPWhite iPWhite)
+ {
+ return iPWhite.Address.Equals(Address);
+ }
+ return false;
+ }
+ }
+}
diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteSecurity.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteSecurity.cs
new file mode 100644
index 000000000..535823329
--- /dev/null
+++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateWay.Admin.Domain/LINGYUN/ApiGateWay/Admin/Security/RouteSecurity.cs
@@ -0,0 +1,56 @@
+using LINGYUN.ApiGateWay.Admin.Routes;
+using System;
+using System.Collections.Generic;
+using Volo.Abp.Domain.Entities;
+
+namespace LINGYUN.ApiGateWay.Admin.Security
+{
+ public class RouteSecurity : Entity
+ {
+ public virtual ICollection IPAllowedList { get; private set; }
+ public virtual ICollection IPBlockedList { get; private set; }
+ public virtual Guid RouteId { get; private set; }
+ public virtual Route Route { get; private set; }
+ protected RouteSecurity()
+ {
+ IPAllowedList = new List();
+ IPBlockedList = new List();
+ }
+
+ public RouteSecurity(Guid id, Guid routeId) : this()
+ {
+ Id = id;
+ RouteId = routeId;
+ }
+
+ public void AddIpWhite(string address)
+ {
+ IPAllowedList.AddIfNotContains(new RouteIPWhite(Id, address));
+ }
+
+ public void RemoveIpWhite(string address)
+ {
+ IPAllowedList.RemoveAll(ip => ip.Address.Equals(address));
+ }
+
+ public void RemoveAllIpWhite()
+ {
+ IPAllowedList.Clear();
+ }
+
+ public void AddIpBlock(string address)
+ {
+ IPBlockedList.AddIfNotContains(new RouteIPBlock(Id, address));
+ }
+
+ public void RemoveIpBlock(string address)
+ {
+ IPBlockedList.RemoveAll(ip => ip.Address.Equals(address));
+ }
+
+ public void RemoveAllIpBlock()
+ {
+ IPBlockedList.Clear();
+ }
+ }
+}
diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Settings/Volo/Abp/Settings/ISettingProviderExtensions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Settings/Volo/Abp/Settings/ISettingProviderExtensions.cs
index 2094283bc..fda1463bb 100644
--- a/aspnet-core/modules/common/LINGYUN.Abp.Settings/Volo/Abp/Settings/ISettingProviderExtensions.cs
+++ b/aspnet-core/modules/common/LINGYUN.Abp.Settings/Volo/Abp/Settings/ISettingProviderExtensions.cs
@@ -24,7 +24,5 @@ namespace Volo.Abp.Settings
}
return value;
}
-
-
}
}
diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN/Abp/PermissionManagement/FixClientPermissionValueProvider.cs b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN/Abp/PermissionManagement/FixClientPermissionValueProvider.cs
new file mode 100644
index 000000000..997c5d9d5
--- /dev/null
+++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN/Abp/PermissionManagement/FixClientPermissionValueProvider.cs
@@ -0,0 +1,30 @@
+using System.Threading.Tasks;
+using Volo.Abp.Authorization.Permissions;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.MultiTenancy;
+
+namespace LINGYUN.Abp.PermissionManagement
+{
+ // fix: https://github.com/abpframework/abp/issues/6022
+ // TODO: 在4.0正式版中已修复此问题,升级后需要移除
+ [Dependency(ReplaceServices = true)]
+ [ExposeServices(typeof(ClientPermissionValueProvider))]
+ public class FixClientPermissionValueProvider : ClientPermissionValueProvider
+ {
+ protected ICurrentTenant CurrentTenant { get; }
+ public FixClientPermissionValueProvider(
+ IPermissionStore permissionStore,
+ ICurrentTenant currentTenant) : base(permissionStore)
+ {
+ CurrentTenant = currentTenant;
+ }
+
+ public override async Task CheckAsync(PermissionValueCheckContext context)
+ {
+ using (CurrentTenant.Change(null))
+ {
+ return await base.CheckAsync(context);
+ }
+ }
+ }
+}
diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
index d1b1471ea..bf844ac2d 100644
--- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
+++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
@@ -70,7 +70,8 @@ namespace LINGYUN.Abp.SettingManagement
}
}
- [Authorize]
+ //[Authorize]
+ [AllowAnonymous]
public virtual async Task> GetAllForCurrentTenantAsync()
{
return await GetAllForProviderAsync(TenantSettingValueProvider.ProviderName, CurrentTenant.GetId().ToString());
diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
index b5e06c379..0f3ef67f0 100644
--- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
+++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -101,6 +102,15 @@ namespace AuthServer.Host
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
Configure(options =>
{
options.UseMySQL();
@@ -183,10 +193,7 @@ namespace AuthServer.Host
options.Audience = configuration["AuthServer:ApiName"];
});
- Configure(options =>
- {
- options.IsEnabled = true;
- });
+
if (!hostingEnvironment.IsDevelopment())
{
@@ -196,6 +203,24 @@ namespace AuthServer.Host
.PersistKeysToStackExchangeRedis(redis, "AuthServer-Protection-Keys");
}
+ Configure(options =>
+ {
+ options.IsEnabled = true;
+ });
+
+ var tenantResolveCfg = configuration.GetSection("App:Domains");
+ if (tenantResolveCfg.Exists())
+ {
+ Configure(options =>
+ {
+ var domains = tenantResolveCfg.Get();
+ foreach (var domain in domains)
+ {
+ options.AddDomainTenantResolver(domain);
+ }
+ });
+ }
+
context.Services.AddCors(options =>
{
options.AddPolicy(DefaultCorsPolicyName, builder =>
@@ -221,6 +246,8 @@ namespace AuthServer.Host
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
+ // 从请求头中解析真实的客户机连接信息
+ app.UseForwardedHeaders();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs
index ae90ae280..813ddbce0 100644
--- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs
+++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs
@@ -1,6 +1,5 @@
using DotNetCore.CAP;
using LINGYUN.Abp.Auditing;
-using LINGYUN.Abp.BackendAdmin.MultiTenancy;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing;
@@ -25,6 +24,8 @@ using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Text;
using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
@@ -121,6 +122,16 @@ namespace LINGYUN.Abp.BackendAdmin
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = hostingEnvironment.BuildConfiguration();
+
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
// 配置Ef
Configure(options =>
{
@@ -207,10 +218,18 @@ namespace LINGYUN.Abp.BackendAdmin
options.IsEnabled = true;
});
- Configure(options =>
+ var tenantResolveCfg = configuration.GetSection("App:Domains");
+ if (tenantResolveCfg.Exists())
{
- options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor());
- });
+ Configure(options =>
+ {
+ var domains = tenantResolveCfg.Get();
+ foreach (var domain in domains)
+ {
+ options.AddDomainTenantResolver(domain);
+ }
+ });
+ }
Configure(options =>
{
@@ -299,6 +318,8 @@ namespace LINGYUN.Abp.BackendAdmin
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
+ // 代理的中间件应放在其他中间件之前
+ app.UseForwardedHeaders();
// http调用链
app.UseCorrelationId();
// 虚拟文件系统
@@ -330,6 +351,8 @@ namespace LINGYUN.Abp.BackendAdmin
if (context.GetEnvironment().IsDevelopment())
{
+ // 开发模式下调试代理连接信息用
+ app.UseProxyConnectTest();
SeedData(context);
}
}
diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
deleted file mode 100644
index 754684c36..000000000
--- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System.Linq;
-using Volo.Abp.AspNetCore.MultiTenancy;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Security.Claims;
-
-namespace LINGYUN.Abp.BackendAdmin.MultiTenancy
-{
- public class AuthorizationTenantResolveContributor : HttpTenantResolveContributorBase
- {
- public override string Name => "Authorization";
-
- protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext)
- {
- if (httpContext.User?.Identity == null)
- {
- return null;
- }
- if (!httpContext.User.Identity.IsAuthenticated)
- {
- return null;
- }
- var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey;
-
- var tenantClaim = httpContext.User.Claims.FirstOrDefault(x => x.Type.Equals(AbpClaimTypes.TenantId));
-
- if (tenantClaim == null)
- {
- return null;
- }
-
- return tenantClaim.Value;
- }
- }
-}
diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Properties/launchSettings.json b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Properties/launchSettings.json
index df9f27d20..9388bc29c 100644
--- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Properties/launchSettings.json
+++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Properties/launchSettings.json
@@ -11,7 +11,7 @@
"LINGYUN.Abp.BackendAdminApp.Host": {
"commandName": "Project",
"launchBrowser": false,
- "applicationUrl": "http://localhost:30010",
+ "applicationUrl": "http://0.0.0.0:30010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddleware.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddleware.cs
new file mode 100644
index 000000000..c69b7874f
--- /dev/null
+++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddleware.cs
@@ -0,0 +1,44 @@
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LINGYUN.Abp.BackendAdmin.Tests
+{
+ public class ProxyConnectTestMiddleware
+ {
+ private readonly RequestDelegate _next;
+ public ProxyConnectTestMiddleware(RequestDelegate next)
+ {
+ _next = next;
+ }
+
+ public async Task Invoke(HttpContext context)
+ {
+ if (context.Request.Path.StartsWithSegments("/api/connect"))
+ {
+ var contentBuilder = new StringBuilder();
+
+ contentBuilder.AppendLine("Connection:");
+ contentBuilder.AppendLine($"Id: {context.Connection.Id}");
+ contentBuilder.AppendLine($"LocalIpAddress: {context.Connection.LocalIpAddress}:{context.Connection.LocalPort}");
+ contentBuilder.AppendLine($"RemoteIpAddress: {context.Connection.RemoteIpAddress}:{context.Connection.RemotePort}");
+ contentBuilder.AppendLine();
+ contentBuilder.AppendLine("Headers:");
+ contentBuilder.Append(context.Request.Headers.Select(h => $"Key:{h.Key}, Value:{h.Value}").JoinAsString(Environment.NewLine));
+ contentBuilder.AppendLine();
+ contentBuilder.AppendLine();
+ contentBuilder.AppendLine("Host:");
+ contentBuilder.AppendLine(context.Request.Host.ToUriComponent());
+ contentBuilder.AppendLine();
+ contentBuilder.AppendLine("Scheme:");
+ contentBuilder.AppendLine(context.Request.Scheme);
+ await context.Response.WriteAsync(contentBuilder.ToString());
+ return;
+ }
+ await _next(context);
+ }
+ }
+}
diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddlewareExtensions.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddlewareExtensions.cs
new file mode 100644
index 000000000..941957760
--- /dev/null
+++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Tests/ProxyConnectTestMiddlewareExtensions.cs
@@ -0,0 +1,12 @@
+using LINGYUN.Abp.BackendAdmin.Tests;
+
+namespace Microsoft.AspNetCore.Builder
+{
+ public static class ProxyConnectTestMiddlewareExtensions
+ {
+ public static IApplicationBuilder UseProxyConnectTest(this IApplicationBuilder app)
+ {
+ return app.UseMiddleware();
+ }
+ }
+}
diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
index cf3e45827..14b3d5414 100644
--- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
+++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
@@ -11,6 +11,7 @@ using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+using Ocelot.Configuration.Creator;
using Ocelot.Configuration.Repository;
using Ocelot.DependencyInjection;
using Ocelot.Extenssions;
@@ -187,6 +188,8 @@ namespace LINGYUN.ApiGateway
{
var app = context.GetApplicationBuilder();
+ // 网关不需要加代理中间件
+
app.UseAuditing();
app.UseVirtualFiles();
app.UseRouting();
diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
index 21f2e7eba..4a95c6bf6 100644
--- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
+++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
@@ -72,6 +72,16 @@ namespace LINGYUN.ApiGateway
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = hostingEnvironment.BuildConfiguration();
+
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
// 配置Ef
Configure(options =>
{
@@ -201,6 +211,8 @@ namespace LINGYUN.ApiGateway
{
var app = context.GetApplicationBuilder();
var configuration = context.GetConfiguration();
+
+ app.UseForwardedHeaders();
// http调用链
app.UseCorrelationId();
// 虚拟文件系统
diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs
index 42a04ffdf..aaf64562b 100644
--- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs
+++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs
@@ -94,6 +94,16 @@ namespace LINGYUN.Abp.IdentityServer4
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = hostingEnvironment.BuildConfiguration();
+
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
// 配置Ef
Configure(options =>
{
@@ -150,8 +160,6 @@ namespace LINGYUN.Abp.IdentityServer4
{
// 是否发送堆栈信息
options.SendStackTrace = true;
- // 未指定异常接收者的默认接收邮件
- options.DefaultReceiveEmail = "colin.in@foxmail.com";
});
Configure(options =>
@@ -201,10 +209,18 @@ namespace LINGYUN.Abp.IdentityServer4
options.IsEnabled = true;
});
- Configure(options =>
+ var tenantResolveCfg = configuration.GetSection("App:Domains");
+ if (tenantResolveCfg.Exists())
{
- options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor());
- });
+ Configure(options =>
+ {
+ var domains = tenantResolveCfg.Get();
+ foreach (var domain in domains)
+ {
+ options.AddDomainTenantResolver(domain);
+ }
+ });
+ }
// Swagger
context.Services.AddSwaggerGen(
@@ -270,6 +286,8 @@ namespace LINGYUN.Abp.IdentityServer4
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
+
+ app.UseForwardedHeaders();
// http调用链
app.UseCorrelationId();
// 虚拟文件系统
diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
deleted file mode 100644
index c9f352286..000000000
--- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System.Linq;
-using Volo.Abp.AspNetCore.MultiTenancy;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Security.Claims;
-
-namespace LINGYUN.Abp.IdentityServer4
-{
- public class AuthorizationTenantResolveContributor : HttpTenantResolveContributorBase
- {
- public override string Name => "Authorization";
-
- protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext)
- {
- if (httpContext.User?.Identity == null)
- {
- return null;
- }
- if (!httpContext.User.Identity.IsAuthenticated)
- {
- return null;
- }
- var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey;
-
- var tenantClaim = httpContext.User.Claims.FirstOrDefault(x => x.Type.Equals(AbpClaimTypes.TenantId));
-
- if (tenantClaim == null)
- {
- return null;
- }
-
- return tenantClaim.Value;
- }
- }
-}
diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs
index b9486b82a..bdd61229e 100644
--- a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs
+++ b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs
@@ -10,7 +10,6 @@ using LINGYUN.Abp.IM.SignalR;
using LINGYUN.Abp.MessageService.Authorization;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Localization;
-using LINGYUN.Abp.MessageService.MultiTenancy;
using LINGYUN.Abp.MultiTenancy.DbFinder;
using LINGYUN.Abp.Notifications.SignalR;
using LINGYUN.Abp.Notifications.Sms;
@@ -95,6 +94,16 @@ namespace LINGYUN.Abp.MessageService
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = hostingEnvironment.BuildConfiguration();
+
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
// 配置Ef
Configure(options =>
{
@@ -141,10 +150,18 @@ namespace LINGYUN.Abp.MessageService
options.IsEnabled = true;
});
- Configure(options =>
+ var tenantResolveCfg = configuration.GetSection("App:Domains");
+ if (tenantResolveCfg.Exists())
{
- options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor());
- });
+ Configure(options =>
+ {
+ var domains = tenantResolveCfg.Get();
+ foreach (var domain in domains)
+ {
+ options.AddDomainTenantResolver(domain);
+ }
+ });
+ }
Configure(options =>
{
@@ -273,6 +290,8 @@ namespace LINGYUN.Abp.MessageService
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
+
+ app.UseForwardedHeaders();
// http调用链
app.UseCorrelationId();
// 虚拟文件系统
diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
deleted file mode 100644
index f0c09657f..000000000
--- a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System.Linq;
-using Volo.Abp.AspNetCore.MultiTenancy;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Security.Claims;
-
-namespace LINGYUN.Abp.MessageService.MultiTenancy
-{
- public class AuthorizationTenantResolveContributor : HttpTenantResolveContributorBase
- {
- public override string Name => "Authorization";
-
- protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext)
- {
- if (httpContext.User?.Identity == null)
- {
- return null;
- }
- if (!httpContext.User.Identity.IsAuthenticated)
- {
- return null;
- }
- var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey;
-
- var tenantClaim = httpContext.User.Claims.FirstOrDefault(x => x.Type.Equals(AbpClaimTypes.TenantId));
-
- if (tenantClaim == null)
- {
- return null;
- }
-
- return tenantClaim.Value;
- }
- }
-}
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
index e5952185c..6db007483 100644
--- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
+++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
@@ -7,7 +7,6 @@ using LINGYUN.Abp.MultiTenancy.DbFinder;
using LINGYUN.Abp.Notifications;
using LINGYUN.Platform.EntityFrameworkCore;
using LINGYUN.Platform.HttpApi;
-using LINGYUN.Platform.MultiTenancy;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
@@ -90,6 +89,16 @@ namespace LINGYUN.Platform
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = hostingEnvironment.BuildConfiguration();
+
+ // 请求代理配置
+ Configure(options =>
+ {
+ configuration.GetSection("App:Forwarded").Bind(options);
+ // 对于生产环境,为安全考虑需要在配置中指定受信任代理服务器
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ });
+
// 配置Ef
Configure(options =>
{
@@ -179,6 +188,19 @@ namespace LINGYUN.Platform
options.IsEnabled = true;
});
+ var tenantResolveCfg = configuration.GetSection("App:Domains");
+ if (tenantResolveCfg.Exists())
+ {
+ Configure(options =>
+ {
+ var domains = tenantResolveCfg.Get();
+ foreach (var domain in domains)
+ {
+ options.AddDomainTenantResolver(domain);
+ }
+ });
+ }
+
Configure(options =>
{
options.ApplicationName = "Platform";
@@ -192,11 +214,6 @@ namespace LINGYUN.Platform
}
});
- Configure(options =>
- {
- options.TenantResolvers.Insert(0, new AuthorizationTenantResolveContributor());
- });
-
// Swagger
context.Services.AddSwaggerGen(
options =>
@@ -265,6 +282,8 @@ namespace LINGYUN.Platform
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
+
+ app.UseForwardedHeaders();
// http调用链
app.UseCorrelationId();
// 虚拟文件系统
diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
deleted file mode 100644
index 1b3bfc666..000000000
--- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/MultiTenancy/AuthorizationTenantResolveContributor.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System.Linq;
-using Volo.Abp.AspNetCore.MultiTenancy;
-using Volo.Abp.MultiTenancy;
-using Volo.Abp.Security.Claims;
-
-namespace LINGYUN.Platform.MultiTenancy
-{
- public class AuthorizationTenantResolveContributor : HttpTenantResolveContributorBase
- {
- public override string Name => "Authorization";
-
- protected override string GetTenantIdOrNameFromHttpContextOrNull(ITenantResolveContext context, HttpContext httpContext)
- {
- if (httpContext.User?.Identity == null)
- {
- return null;
- }
- if (!httpContext.User.Identity.IsAuthenticated)
- {
- return null;
- }
- var tenantIdKey = context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey;
-
- var tenantClaim = httpContext.User.Claims.FirstOrDefault(x => x.Type.Equals(AbpClaimTypes.TenantId));
-
- if (tenantClaim == null)
- {
- return null;
- }
-
- return tenantClaim.Value;
- }
- }
-}