Browse Source

Added WebGateway

pull/1/head
Galip Tolga Erdem 5 years ago
parent
commit
fc1a4fe54b
  1. 7
      EShopOnAbp.sln
  2. 2
      apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json
  3. 32
      gateways/web/EShopOnAbp.WebGateway.sln
  4. 13
      gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs
  5. 22
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj
  6. 74
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs
  7. 46
      gateways/web/src/EShopOnAbp.WebGateway/Program.cs
  8. 29
      gateways/web/src/EShopOnAbp.WebGateway/Properties/launchSettings.json
  9. 19
      gateways/web/src/EShopOnAbp.WebGateway/Startup.cs
  10. 9
      gateways/web/src/EShopOnAbp.WebGateway/appsettings.Development.json
  11. 115
      gateways/web/src/EShopOnAbp.WebGateway/appsettings.json
  12. 2
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json

7
EShopOnAbp.sln

@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.Shared.Hosting.G
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.InternalGateway", "gateways\internal\src\EShopOnAbp.InternalGateway\EShopOnAbp.InternalGateway.csproj", "{857EE54A-6116-46AA-AB34-50B19E51DB3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.WebGateway", "gateways\web\src\EShopOnAbp.WebGateway\EShopOnAbp.WebGateway.csproj", "{5D653BE4-7653-4684-B9F0-9A9B955093E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -77,6 +79,10 @@ Global
{857EE54A-6116-46AA-AB34-50B19E51DB3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857EE54A-6116-46AA-AB34-50B19E51DB3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857EE54A-6116-46AA-AB34-50B19E51DB3B}.Release|Any CPU.Build.0 = Release|Any CPU
{5D653BE4-7653-4684-B9F0-9A9B955093E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D653BE4-7653-4684-B9F0-9A9B955093E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D653BE4-7653-4684-B9F0-9A9B955093E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D653BE4-7653-4684-B9F0-9A9B955093E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -92,6 +98,7 @@ Global
{FDFCA1B4-FD9D-445C-8655-3DF3F2D57CEA} = {F415FFFD-E52D-4EBE-98DC-067C1EFFFFE3}
{590B609C-5887-4896-9FC5-5E54A2658B18} = {B8B59303-2178-459B-91A8-DF353044E090}
{857EE54A-6116-46AA-AB34-50B19E51DB3B} = {1484E912-DCF3-4568-A72C-4C7622104DB8}
{5D653BE4-7653-4684-B9F0-9A9B955093E5} = {1484E912-DCF3-4568-A72C-4C7622104DB8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {26F82565-C6A4-439D-93A4-3251E3E7D5B0}

2
apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json

@ -1,7 +1,7 @@
{
"App": {
"SelfUrl": "https://localhost:44330",
"CorsOrigins": "https://*.EShopOnAbp.com,http://localhost:4200,https://localhost:44307,https://localhost:44371,https://localhost:44325,https://localhost:44353",
"CorsOrigins": "https://*.EShopOnAbp.com,http://localhost:4200,https://localhost:44307,https://localhost:44371,https://localhost:44372,https://localhost:44353",
"RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307"
},
"Logging": {

32
gateways/web/EShopOnAbp.WebGateway.sln

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31320.298
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{138BBFFC-09B9-49FB-9C57-E25327CCE0C1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A5E7F07B-7A5D-416D-A9E0-2009A48CBE2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.WebGateway", "src\EShopOnAbp.WebGateway\EShopOnAbp.WebGateway.csproj", "{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C3A2AC7A-A50C-4C80-BE68-7FBBAD09D981} = {138BBFFC-09B9-49FB-9C57-E25327CCE0C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1753A143-A9EF-43ED-970D-C71BAD179AE6}
EndGlobalSection
EndGlobal

13
gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
namespace EShopOnAbp.WebGateway.Controllers
{
public class HomeController : AbpController
{
public ActionResult Index()
{
return Redirect("/swagger");
}
}
}

22
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Gateways\EShopOnAbp.Shared.Hosting.Gateways.csproj" />
<ProjectReference Include="..\..\..\..\services\identity\src\EShopOnAbp.IdentityService.HttpApi\EShopOnAbp.IdentityService.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\services\saas\src\EShopOnAbp.SaasService.HttpApi\EShopOnAbp.SaasService.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\services\administration\src\EShopOnAbp.AdministrationService.HttpApi\EShopOnAbp.AdministrationService.HttpApi.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
</ItemGroup>
</Project>

74
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

@ -0,0 +1,74 @@
using System.Collections.Generic;
using EShopOnAbp.AdministrationService;
using EShopOnAbp.IdentityService;
using EShopOnAbp.SaasService;
using EShopOnAbp.Shared.Hosting.Gateways;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.Middleware;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace EShopOnAbp.WebGateway
{
[DependsOn(
typeof(EShopOnAbpSharedHostingGatewaysModule),
typeof(IdentityServiceHttpApiModule),
typeof(SaasServiceHttpApiModule),
typeof(AdministrationServiceHttpApiModule)
)]
public class EShopOnAbpWebGatewayModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"IdentityService", "Identity Service API"},
{"AdministrationService", "Administration Service API"},
{"SaasService", "Saas Service API"},
},
apiTitle: "Web Gateway API"
);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Web Gateway API");
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
});
app.UseAbpSerilogEnrichers();
app.MapWhen(
ctx => ctx.Request.Path.ToString().StartsWith("/api/abp/api-definition") ||
ctx.Request.Path.ToString().TrimEnd('/').Equals(""),
app2 =>
{
app2.UseRouting();
app2.UseConfiguredEndpoints();
}
);
app.UseOcelot().Wait();
}
}
}

46
gateways/web/src/EShopOnAbp.WebGateway/Program.cs

@ -0,0 +1,46 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace EShopOnAbp.WebGateway
{
public class Program
{
public static async Task<int> Main(string[] args)
{
var assemblyName = typeof(Program).Assembly.GetName().Name;
SerilogConfigurationHelper.Configure(assemblyName);
try
{
Log.Information($"Starting {assemblyName}.");
await CreateHostBuilder(args).Build().RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(build =>
{
build.AddJsonFile("appsettings.secrets.json", optional: true);
})
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
.UseAutofac()
.UseSerilog();
}
}

29
gateways/web/src/EShopOnAbp.WebGateway/Properties/launchSettings.json

@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44372",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"EShopOnAbp.WebGateway": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "https://localhost:44372",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

19
gateways/web/src/EShopOnAbp.WebGateway/Startup.cs

@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace EShopOnAbp.WebGateway
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<EShopOnAbpWebGatewayModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.InitializeApplication();
}
}
}

9
gateways/web/src/EShopOnAbp.WebGateway/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

115
gateways/web/src/EShopOnAbp.WebGateway/appsettings.json

@ -0,0 +1,115 @@
{
"App": {
"SelfUrl": "https://localhost:44372",
"CorsOrigins": "http://localhost:4200"
},
"AuthServer": {
"Authority": "https://localhost:44330",
"RequireHttpsMetadata": "true",
"SwaggerClientId": "WebGateway_Swagger",
"SwaggerClientSecret": "1q2w3e*"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Routes": [
{
"DownstreamPathTemplate": "/api/identity/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44351
}
],
"UpstreamPathTemplate": "/api/identity/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44351
}
],
"UpstreamPathTemplate": "/api/account/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/saas/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44352
}
],
"UpstreamPathTemplate": "/api/saas/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/abp/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/abp/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/feature-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/feature-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/permission-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/permission-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
},
{
"DownstreamPathTemplate": "/api/setting-management/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44353
}
],
"UpstreamPathTemplate": "/api/setting-management/{everything}",
"UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44372"
},
"Redis": {
"Configuration": "localhost:6379"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
}
}

2
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json

@ -50,7 +50,7 @@
"RootUrl": "https://localhost:44371"
},
"WebGateway": {
"RootUrl": "https://localhost:44325"
"RootUrl": "https://localhost:44372"
},
"PublicWebGateway": {
"RootUrl": "https://localhost:44353"

Loading…
Cancel
Save