Browse Source

Added Web-Public Gateway

pull/1/head
Galip Tolga Erdem 5 years ago
parent
commit
875cdc414f
  1. 7
      EShopOnAbp.sln
  2. 32
      gateways/web-public/EShopOnAbp.WebPublicGateway.sln
  3. 13
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs
  4. 22
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj
  5. 67
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs
  6. 46
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/Program.cs
  7. 29
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/Properties/launchSettings.json
  8. 19
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/Startup.cs
  9. 9
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Development.json
  10. 55
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json
  11. 2
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs
  12. 4
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json

7
EShopOnAbp.sln

@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.InternalGateway"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.WebGateway", "gateways\web\src\EShopOnAbp.WebGateway\EShopOnAbp.WebGateway.csproj", "{5D653BE4-7653-4684-B9F0-9A9B955093E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.WebPublicGateway", "gateways\web-public\src\EShopOnAbp.WebPublicGateway\EShopOnAbp.WebPublicGateway.csproj", "{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -83,6 +85,10 @@ Global
{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
{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -99,6 +105,7 @@ Global
{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}
{2E0B715C-3AAD-47B3-B2EB-D34CB24CBEFA} = {1484E912-DCF3-4568-A72C-4C7622104DB8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {26F82565-C6A4-439D-93A4-3251E3E7D5B0}

32
gateways/web-public/EShopOnAbp.WebPublicGateway.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.WebPublicGateway", "src\EShopOnAbp.WebPublicGateway\EShopOnAbp.WebPublicGateway.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-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs

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

22
gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="4.3.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Gateways\EShopOnAbp.Shared.Hosting.Gateways.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
</ItemGroup>
</Project>

67
gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs

@ -0,0 +1,67 @@
using System.Collections.Generic;
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.Account;
using Volo.Abp.Modularity;
namespace EShopOnAbp.WebPublicGateway
{
[DependsOn(
typeof(EShopOnAbpSharedHostingGatewaysModule),
typeof(AbpAccountHttpApiModule)
)]
public class EShopOnAbpWebPublicGatewayModule : 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 */
{
},
apiTitle: "WebPublic 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 Public 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-public/src/EShopOnAbp.WebPublicGateway/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.WebPublicGateway
{
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-public/src/EShopOnAbp.WebPublicGateway/Properties/launchSettings.json

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

19
gateways/web-public/src/EShopOnAbp.WebPublicGateway/Startup.cs

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

9
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Development.json

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

55
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json

@ -0,0 +1,55 @@
{
"App": {
"SelfUrl": "https://localhost:44373",
"CorsOrigins": "https://localhost:44335"
},
"AuthServer": {
"Authority": "https://localhost:44330",
"RequireHttpsMetadata": "true",
"SwaggerClientId": "WebPublicGateway_Swagger",
"SwaggerClientSecret": "1q2w3e*"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Routes": [
{
"DownstreamPathTemplate": "/api/account/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 44351
}
],
"UpstreamPathTemplate": "/api/account/{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" ]
}
],
"GlobalConfiguration": {
"BaseUrl": "https://localhost:44373"
},
"Redis": {
"Configuration": "localhost:6379"
},
"ElasticSearch": {
"Url": "http://localhost:9200"
}
}

2
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs

@ -95,7 +95,7 @@ namespace EShopOnAbp.IdentityService.DbMigrations
new[] { "IdentityService", "AdministrationService", "SaasService" });
await CreateSwaggerClientAsync("WebGateway",
new[] { "IdentityService", "AdministrationService", "SaasService" });
await CreateSwaggerClientAsync("PublicWebGateway", new[] { "" });
await CreateSwaggerClientAsync("WebPublicGateway" );
}
private async Task CreateSwaggerClientAsync(string name, string[] scopes = null)

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

@ -52,8 +52,8 @@
"WebGateway": {
"RootUrl": "https://localhost:44372"
},
"PublicWebGateway": {
"RootUrl": "https://localhost:44353"
"WebPublicGateway": {
"RootUrl": "https://localhost:44373"
}
}
}

Loading…
Cancel
Save