Browse Source

Merge pull request #84 from colinin/3.1

Security-related submissions
pull/115/head
cKey 5 years ago
committed by GitHub
parent
commit
7426e29457
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json
  2. 2
      aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json
  3. 3
      aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN/ApiGateway/Localization/DomainShared/en.json
  4. 3
      aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN/ApiGateway/Localization/DomainShared/zh-Hans.json
  5. 18
      aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs
  6. 32
      aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs
  7. 1
      aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj
  8. 68
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs
  9. 50
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Controllers/ApiGatewayController.cs
  10. 8
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj
  11. 10
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Localization/Host/en.json
  12. 10
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Localization/Host/zh-Hans.json
  13. 21
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Utils/ILoadBalancerFinder.cs
  14. 58
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Utils/LoadBalancerFinder.cs
  15. 35
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs
  16. 2
      aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj
  17. 32
      aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs
  18. 1
      aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj
  19. 32
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs
  20. 1
      aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj
  21. 41
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs
  22. 1
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj
  23. 16
      vueJs/src/api/apigateway.ts
  24. 3
      vueJs/src/lang/en.ts
  25. 3
      vueJs/src/lang/zh.ts
  26. 29
      vueJs/src/views/admin/apigateway/components/AggregateRouteCreateOrEditForm.vue
  27. 21
      vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue
  28. 25
      vueJs/src/views/admin/apigateway/components/RouteCreateOrEditForm.vue

2
aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.Host/appsettings.Development.json

@ -43,7 +43,7 @@
}
},
"AuthServer": {
"Host": "http://localhost:44385/",//IdentityServer
"Authority": "http://localhost:44385/",//IdentityServer
"ApiName": "apigateway-service",//IdentityServerApiName
"ApiSecret": "defj98734htgrb90365D23"//IdentityServerApiSecret
},

2
aspnet-core/configuration/apigateway/LINGYUN.ApiGateway.HttpApi.Host/appsettings.Development.json

@ -28,7 +28,7 @@
}
},
"AuthServer": {
"Host": "http://localhost:44385/",
"Authority": "http://localhost:44385/",
"ApiName": "apigateway-service",
"ApiSecret": "defj98734htgrb90365D23"
},

3
aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN/ApiGateway/Localization/DomainShared/en.json

@ -38,9 +38,6 @@
"UseTracing": "Http track",
"LoadBalancer": "Load balancer",
"LoadWay": "Balancer type",
"LeastConnection": "Least connection",
"RoundRobin": "Round robin",
"NoLoadBalance": "No load balance",
"ServiceDiscovery": "Service discovery",
"DiscoveryType": "Service type",
"Host": "Host",

3
aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN/ApiGateway/Localization/DomainShared/zh-Hans.json

@ -38,9 +38,6 @@
"UseTracing": "HTTP追踪",
"LoadBalancer": "负载均衡",
"LoadWay": "负载方式",
"LeastConnection": "总是空闲服务器",
"RoundRobin": "服务器轮询",
"NoLoadBalance": "发往首个服务器",
"ServiceDiscovery": "服务发现",
"DiscoveryType": "实例类型",
"Host": "主机地址",

18
aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs

@ -77,10 +77,6 @@ namespace AuthServer.Host
})
.UseDashboard();
});
PreConfigure<IIdentityServerBuilder>(builder =>
{
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
@ -96,9 +92,17 @@ namespace AuthServer.Host
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<AbpDistributedCacheOptions>(options =>

32
aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.cs

@ -53,6 +53,9 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Security.Claims;
using System.Collections.Generic;
namespace LINGYUN.Abp.BackendAdmin
{
@ -122,9 +125,17 @@ namespace LINGYUN.Abp.BackendAdmin
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<PermissionManagementOptions>(options =>
@ -246,16 +257,17 @@ namespace LINGYUN.Abp.BackendAdmin
new NameValue("en", "en"));
});
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
Configure<AbpClaimsMapOptions>(options =>
{
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.Email = JwtClaimTypes.Email;
options.Audience = configuration["AuthServer:ApiName"];
});
if (!hostingEnvironment.IsDevelopment())

1
aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj

@ -31,7 +31,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="3.1.7" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />

68
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.cs

@ -1,6 +1,9 @@
using DotNetCore.CAP;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.ApiGateway.Localization;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -11,15 +14,21 @@ using Ocelot.Middleware.Multiplexer;
using Ocelot.Provider.Polly;
using StackExchange.Redis;
using System;
using System.Text;
using Volo.Abp;
using Volo.Abp.AspNetCore;
using Volo.Abp.AspNetCore.Security.Claims;
using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.IdentityModel;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Security.Claims;
using Volo.Abp.Security.Encryption;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.ApiGateway
{
@ -68,13 +77,17 @@ namespace LINGYUN.ApiGateway
Configure<ApiGatewayOptions>(configuration.GetSection("ApiGateway"));
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
Configure<AbpClaimsMapOptions>(options =>
{
options.Authority = configuration["AuthServer:Host"];
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
options.ApiSecret = configuration["AuthServer:ApiSecret"];
options.Audience = configuration["AuthServer:ApiName"];
});
Configure<AbpDistributedCacheOptions>(options =>
@ -100,12 +113,55 @@ namespace LINGYUN.ApiGateway
options.InstanceName = configuration["Redis:InstanceName"];
});
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<ApiGatewayHostModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Resources
.Get<ApiGatewayResource>()
.AddVirtualJson("/Localization/Host");
});
Configure<IdentityModelHttpRequestMessageOptions>(options =>
{
// See https://github.com/abpframework/abp/pull/4564
options.ConfigureHttpRequestMessage = (requestMessage) => { };
});
var mvcBuilder = context.Services.AddMvc();
mvcBuilder.AddApplicationPart(typeof(ApiGatewayHostModule).Assembly);
Configure<AbpEndpointRouterOptions>(options =>
{
options.EndpointConfigureActions.Add(endpointContext =>
{
endpointContext.Endpoints.MapControllerRoute("defaultWithArea", "{area}/{controller=Home}/{action=Index}/{id?}");
endpointContext.Endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
});
context.Services
.AddOcelot()
.AddPolly()
@ -117,6 +173,8 @@ namespace LINGYUN.ApiGateway
var app = context.GetApplicationBuilder();
app.UseAuditing();
app.UseRouting();
app.UseConfiguredEndpoints();
// 启用ws协议
app.UseWebSockets();
app.UseOcelot().Wait();

50
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Controllers/ApiGatewayController.cs

@ -0,0 +1,50 @@
using LINGYUN.ApiGateway.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Multiplexer;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.ApiGateway.Controllers
{
[RemoteService(Name = ApiGatewayConsts.RemoteServiceName)]
[Area("ApiGateway")]
[Route("api/ApiGateway/Basic")]
public class ApiGatewayController : Controller
{
protected IServiceProvider ServiceProvider { get; }
protected ILoadBalancerFinder LoadBalancerFinder { get; }
public ApiGatewayController(
IServiceProvider serviceProvider,
ILoadBalancerFinder loadBalancerFinder)
{
ServiceProvider = serviceProvider;
LoadBalancerFinder = loadBalancerFinder;
}
[HttpGet]
[Route("Aggregators")]
public Task<JsonResult> GetAggregatorsAsync()
{
var aggregators = ServiceProvider.GetServices<IDefinedAggregator>();
var aggregatorDtos = new ListResultDto<string>(aggregators.Select(agg => agg.GetType().Name).ToList());
return Task.FromResult(Json(aggregatorDtos));
}
[HttpGet]
[Route("LoadBalancers")]
public async Task<JsonResult> GetLoadBalancersAsync()
{
var loadBalancers = await LoadBalancerFinder.GetLoadBalancersAsync();
var loadBalancerDtos = new ListResultDto<LoadBalancerDescriptor>(loadBalancers);
return Json(loadBalancerDtos);
}
}
}

8
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj

@ -5,6 +5,11 @@
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\Host\en.json" />
<EmbeddedResource Include="Localization\Host\zh-Hans.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="3.0.4" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="3.0.4" />
@ -16,10 +21,11 @@
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="3.1.0" />
<PackageReference Include="Volo.Abp.AspNetCore" Version="3.1.0" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="3.1.0" />
</ItemGroup>

10
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Localization/Host/en.json

@ -0,0 +1,10 @@
{
"culture": "en",
"texts": {
"NoLoadBalancer": "No Load balancer",
"RoundRobin": "Round robin",
"LeastConnection": "Least connection",
"CookieStickySessions": "Cookie sticky sessions",
"CustomLoadBalancer": "Custom load balancer - {0}"
}
}

10
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Localization/Host/zh-Hans.json

@ -0,0 +1,10 @@
{
"culture": "zh-Hans",
"texts": {
"NoLoadBalancer": "无负载均衡",
"RoundRobin": "服务器轮询",
"LeastConnection": "总是空闲服务器",
"CookieStickySessions": "粘性会话类型",
"CustomLoadBalancer": "自定义负载均衡器 - {0}"
}
}

21
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Utils/ILoadBalancerFinder.cs

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LINGYUN.ApiGateway.Utils
{
public interface ILoadBalancerFinder
{
Task<List<LoadBalancerDescriptor>> GetLoadBalancersAsync();
}
public class LoadBalancerDescriptor
{
public string Type { get; }
public string DisplayName { get; }
public LoadBalancerDescriptor(string type, string displayName)
{
Type = type;
DisplayName = displayName;
}
}
}

58
aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/Utils/LoadBalancerFinder.cs

@ -0,0 +1,58 @@
using LINGYUN.ApiGateway.Localization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Ocelot.LoadBalancer.LoadBalancers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.ApiGateway.Utils
{
public class LoadBalancerFinder : ILoadBalancerFinder, ISingletonDependency
{
private Lazy<List<LoadBalancerDescriptor>> lazyLoadBalancers;
protected List<LoadBalancerDescriptor> LoadBalancers => lazyLoadBalancers.Value;
protected IServiceProvider ServiceProvider { get; }
protected IStringLocalizer Localizer { get; }
public LoadBalancerFinder(
IServiceProvider serviceProvider,
IStringLocalizer<ApiGatewayResource> localizer)
{
Localizer = localizer;
ServiceProvider = serviceProvider;
lazyLoadBalancers = new Lazy<List<LoadBalancerDescriptor>>(() => FindLocalLoadBalancers());
}
public Task<List<LoadBalancerDescriptor>> GetLoadBalancersAsync()
{
return Task.FromResult(LoadBalancers);
}
protected List<LoadBalancerDescriptor> FindLocalLoadBalancers()
{
List<LoadBalancerDescriptor> loadBalancers = new List<LoadBalancerDescriptor>
{
new LoadBalancerDescriptor(typeof(NoLoadBalancer).Name, Localizer["NoLoadBalancer"]),
new LoadBalancerDescriptor(typeof(RoundRobin).Name, Localizer["RoundRobin"]),
new LoadBalancerDescriptor(typeof(LeastConnection).Name, Localizer["LeastConnection"]),
new LoadBalancerDescriptor(typeof(CookieStickySessions).Name, Localizer["CookieStickySessions"])
};
var loadBalancerCreators = ServiceProvider.GetServices<ILoadBalancerCreator>();
loadBalancerCreators = loadBalancerCreators
.Where(lbc => !loadBalancers.Any(l => l.Type.Equals(lbc.Type)))
.ToArray();
foreach(var defintedLoadBalancerCreator in loadBalancerCreators)
{
loadBalancers.Add(new LoadBalancerDescriptor(defintedLoadBalancerCreator.Type, Localizer["CustomLoadBalancer", defintedLoadBalancerCreator.Type]));
}
return loadBalancers;
}
}
}

35
aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.cs

@ -1,8 +1,8 @@
using DotNetCore.CAP;
using IdentityModel;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.MultiTenancy.DbFinder;
using LINGYUN.ApiGateway.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
@ -15,6 +15,7 @@ using StackExchange.Redis;
using System;
using System.Text;
using Volo.Abp;
using Volo.Abp.AspNetCore.Security.Claims;
using Volo.Abp.Autofac;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
@ -77,9 +78,17 @@ namespace LINGYUN.ApiGateway
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<AbpDistributedCacheOptions>(options =>
@ -151,17 +160,17 @@ namespace LINGYUN.ApiGateway
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
});
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
Configure<AbpClaimsMapOptions>(options =>
{
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Host"];
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
options.ApiSecret = configuration["AuthServer:ApiSecret"];
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.Email = JwtClaimTypes.Email;
options.Audience = configuration["AuthServer:ApiName"];
});
if (!hostingEnvironment.IsDevelopment())

2
aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj

@ -19,7 +19,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="3.1.7" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
@ -27,6 +26,7 @@
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="3.1.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="3.1.0" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="3.1.0" />

32
aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.cs

@ -5,6 +5,7 @@ using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.MultiTenancy.DbFinder;
using LINYUN.Abp.Sms.Aliyun;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
@ -13,6 +14,7 @@ using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using System;
@ -21,6 +23,7 @@ using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
using Volo.Abp.AspNetCore.Security.Claims;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Autofac;
using Volo.Abp.Caching;
@ -102,9 +105,17 @@ namespace LINGYUN.Abp.IdentityServer4
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<PermissionManagementOptions>(options =>
@ -216,16 +227,17 @@ namespace LINGYUN.Abp.IdentityServer4
.AddVirtualJson("/LINGYUN/Abp/IdentityServer4/Localization");
});
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
Configure<AbpClaimsMapOptions>(options =>
{
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.Email = JwtClaimTypes.Email;
options.Audience = configuration["AuthServer:ApiName"];
});
if (!hostingEnvironment.IsDevelopment())

1
aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj

@ -24,7 +24,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="3.1.7" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />

32
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.cs

@ -1,6 +1,5 @@
using DotNetCore.CAP;
using Hangfire;
using IdentityModel;
using LINGYUN.Abp.BackgroundJobs.Hangfire;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling;
@ -14,6 +13,7 @@ using LINGYUN.Abp.MessageService.MultiTenancy;
using LINGYUN.Abp.MultiTenancy.DbFinder;
using LINGYUN.Abp.Notifications.SignalR;
using LINGYUN.Abp.Notifications.WeChat.WeApp;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
@ -30,6 +30,7 @@ using System.Text;
using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Security.Claims;
using Volo.Abp.Autofac;
using Volo.Abp.Caching;
using Volo.Abp.Caching.StackExchangeRedis;
@ -99,9 +100,17 @@ namespace LINGYUN.Abp.MessageService
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
Configure<AbpExceptionHandlingOptions>(options =>
@ -233,16 +242,17 @@ namespace LINGYUN.Abp.MessageService
.AddVirtualJson("/Localization/HttpApiHost");
});
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
Configure<AbpClaimsMapOptions>(options =>
{
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.Email = JwtClaimTypes.Email;
options.Audience = configuration["AuthServer:ApiName"];
});
if (!hostingEnvironment.IsDevelopment())

1
aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj

@ -24,7 +24,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="3.1.7" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />

41
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs

@ -1,5 +1,4 @@
using DotNetCore.CAP;
using IdentityModel;
using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing;
@ -9,6 +8,7 @@ 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;
using Microsoft.AspNetCore.Hosting;
@ -25,6 +25,7 @@ using System.Text;
using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.AspNetCore.Security.Claims;
using Volo.Abp.Autofac;
using Volo.Abp.BlobStoring;
using Volo.Abp.BlobStoring.FileSystem;
@ -112,9 +113,17 @@ namespace LINGYUN.Platform
// 加解密
Configure<AbpStringEncryptionOptions>(options =>
{
options.DefaultPassPhrase = "s46c5q55nxpeS8Ra";
options.InitVectorBytes = Encoding.ASCII.GetBytes("s83ng0abvd02js84");
options.DefaultSalt = Encoding.ASCII.GetBytes("sf&5)s3#");
var encryptionConfiguration = configuration.GetSection("Encryption");
if (encryptionConfiguration.Exists())
{
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase;
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"])
: options.DefaultSalt;
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists()
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"])
: options.InitVectorBytes;
}
});
// 自定义需要处理的异常
@ -211,29 +220,19 @@ namespace LINGYUN.Platform
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
});
options
.AddLanguagesMapOrUpdate(
"vue-admin-element-ui",
new NameValue("zh-Hans", "zh"),
new NameValue("en", "en"));
options
.AddLanguageFilesMapOrUpdate(
"vue-admin-element-ui",
new NameValue("zh-Hans", "zh"),
new NameValue("en", "en"));
Configure<AbpClaimsMapOptions>(options =>
{
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName);
});
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = false;
options.ApiName = configuration["AuthServer:ApiName"];
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.UserName = JwtClaimTypes.Name;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.Email = JwtClaimTypes.Email;
options.Audience = configuration["AuthServer:ApiName"];
});
if (!hostingEnvironment.IsDevelopment())

1
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj

@ -28,7 +28,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="3.1.7" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Enrichers.Assembly" Version="2.0.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />

16
vueJs/src/api/apigateway.ts

@ -164,6 +164,17 @@ export default class ApiGateWay {
_url += '&ReRouteKey=' + routeKey
return ApiService.Delete(_url, serviceUrl)
}
public static getDefinedAggregatorProviders() {
const _url = '/api/ApiGateway/Basic/Aggregators'
return ApiService.Get<ListResultDto<string>>(_url, serviceUrl)
}
public static getLoadBalancerProviders() {
const _url = '/api/ApiGateway/Basic/LoadBalancers'
return ApiService.Get<ListResultDto<LoadBalancerDescriptor>>(_url, serviceUrl)
}
}
export class ServiceDiscoveryProvider {
@ -559,3 +570,8 @@ export class AggregateReRouteGetByPaged extends PagedAndSortedResultRequestDto {
return new AggregateReRouteGetByPaged()
}
}
export class LoadBalancerDescriptor {
type!: string
displayName!: string
}

3
vueJs/src/lang/en.ts

@ -420,7 +420,8 @@ export default {
createAggregateRouteConfig: '新建路由配置',
aggregateRouteKey: '路由标识',
aggregateParameter: '聚合参数',
aggregateJsonPath: 'Json路径'
aggregateJsonPath: 'Json路径',
definedAggregatorProviders: '聚合提供者'
},
identityServer: {
otherOpera: '更多操作',

3
vueJs/src/lang/zh.ts

@ -424,7 +424,8 @@ export default {
createAggregateRouteConfig: '新建路由配置',
aggregateRouteKey: '路由标识',
aggregateParameter: '聚合参数',
aggregateJsonPath: 'Json路径'
aggregateJsonPath: 'Json路径',
definedAggregatorProviders: '聚合提供者'
},
identityServer: {
otherOpera: '更多操作',

29
vueJs/src/views/admin/apigateway/components/AggregateRouteCreateOrEditForm.vue

@ -27,8 +27,6 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item
prop="name"
:label="$t('apiGateWay.aggregateRouteName')"
@ -38,6 +36,26 @@
:placeholder="$t('pleaseInputBy', {key: $t('apiGateWay.aggregateRouteName')})"
/>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item
prop="aggregator"
:label="$t('apiGateWay.definedAggregatorProviders')"
>
<el-select
v-model="aggregateRoute.aggregator"
clearable
style="width: 100%"
:placeholder="$t('pleaseSelectBy', {name: $t('apiGateWay.definedAggregatorProviders')})"
>
<el-option
v-for="(provider, index) in definedAggregatorProviders"
:key="index"
:label="provider"
:value="provider"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
@ -139,6 +157,7 @@ export default class extends Vue {
private appIdOptions!: RouteGroupAppIdDto[]
private aggregateRoute: AggregateReRoute
private definedAggregatorProviders = new Array<string>()
get isEditRoute() {
if (this.aggregateRouteId) {
@ -175,6 +194,12 @@ export default class extends Vue {
this.aggregateRoute = AggregateReRoute.empty()
}
mounted() {
ApiGatewayService.getDefinedAggregatorProviders().then(res => {
this.definedAggregatorProviders = res.items
})
}
@Watch('aggregateRouteId', { immediate: true })
private onAggregateRouteIdChanged() {
if (this.aggregateRouteId) {

21
vueJs/src/views/admin/apigateway/components/GlobalCreateOrEditForm.vue

@ -211,20 +211,15 @@
>
<el-select
v-model="globalConfiguration.loadBalancerOptions.type"
clearable
class="global-select"
:placeholder="$t('pleaseSelectBy', {key: $t('apiGateWay.loadBalancerType')})"
>
<el-option
:label="$t('apiGateWay.leastConnection')"
value="LeastConnection"
/>
<el-option
:label="$t('apiGateWay.roundRobin')"
value="RoundRobin"
/>
<el-option
:label="$t('apiGateWay.noLoadBalance')"
value="NoLoadBalance"
v-for="provider in loadBalancerProviders"
:key="provider.type"
:label="provider.displayName"
:value="provider.type"
/>
</el-select>
</el-form-item>
@ -360,6 +355,7 @@ import { checkPermission } from '@/utils/permission'
import { Component, Vue, Prop, Watch } from 'vue-property-decorator'
import ApiGatewayService, {
RouteGroupAppIdDto,
LoadBalancerDescriptor,
GlobalConfigurationDto,
GlobalConfigurationCreateDto,
GlobalConfigurationUpdateDto
@ -378,11 +374,13 @@ export default class extends Vue {
private globalConfiguration: GlobalConfigurationDto
private routeGroupAppIdOptions: RouteGroupAppIdDto[]
private loadBalancerProviders: LoadBalancerDescriptor[]
constructor() {
super()
this.globalConfiguration = new GlobalConfigurationDto()
this.routeGroupAppIdOptions = new Array<RouteGroupAppIdDto>()
this.loadBalancerProviders = new Array<LoadBalancerDescriptor>()
}
get hasEdit() {
@ -405,6 +403,9 @@ export default class extends Vue {
ApiGatewayService.getRouteGroupAppIds().then(appKeys => {
this.routeGroupAppIdOptions = appKeys.items
})
ApiGatewayService.getLoadBalancerProviders().then(res => {
this.loadBalancerProviders = res.items
})
}
@Watch('appId', { immediate: true })

25
vueJs/src/views/admin/apigateway/components/RouteCreateOrEditForm.vue

@ -392,20 +392,15 @@
>
<el-select
v-model="apiGateWayRoute.loadBalancerOptions.type"
clearable
class="route-select"
:placeholder="$t('pleaseSelectBy', {key: $t('apiGateWay.loadBalancerType')})"
>
<el-option
:label="$t('apiGateWay.leastConnection')"
value="LeastConnection"
/>
<el-option
:label="$t('apiGateWay.roundRobin')"
value="RoundRobin"
/>
<el-option
:label="$t('apiGateWay.noLoadBalance')"
value="NoLoadBalance"
v-for="provider in loadBalancerProviders"
:key="provider.type"
:label="provider.displayName"
:value="provider.type"
/>
</el-select>
</el-form-item>
@ -545,7 +540,7 @@ import ElInputTag from '@/components/InputTag/index.vue'
import HostAndPortInputTag from './HostAndPortInputTag.vue'
import DictionaryInputTag from './DictionaryInputTag.vue'
import { Component, Vue, Prop, Watch } from 'vue-property-decorator'
import ApiGateWayService, { RouteGroupAppIdDto, ReRouteDto, ReRouteCreateDto, ReRouteUpdateDto } from '@/api/apigateway'
import ApiGateWayService, { LoadBalancerDescriptor, RouteGroupAppIdDto, ReRouteDto, ReRouteCreateDto, ReRouteUpdateDto } from '@/api/apigateway'
@Component({
name: 'RouteCreateOrEditForm',
@ -564,6 +559,7 @@ export default class extends Vue {
private activeTablePane: string
private apiGateWayRoute: ReRouteDto
private loadBalancerProviders: LoadBalancerDescriptor[]
private httpMethodsFilter: { [key: string]: string } = {
GET: '',
POST: 'success',
@ -622,6 +618,13 @@ export default class extends Vue {
super()
this.activeTablePane = 'basicOptions'
this.apiGateWayRoute = new ReRouteDto()
this.loadBalancerProviders = new Array<LoadBalancerDescriptor>()
}
mounted() {
ApiGateWayService.getLoadBalancerProviders().then(res => {
this.loadBalancerProviders = res.items
})
}
@Watch('routeId', { immediate: true })

Loading…
Cancel
Save