diff --git a/EShopOnAbp.sln b/EShopOnAbp.sln index 3cef443c..e5ac894c 100644 --- a/EShopOnAbp.sln +++ b/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} diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json b/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json index 238a6f0f..81e84e8e 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json +++ b/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": { diff --git a/gateways/web/EShopOnAbp.WebGateway.sln b/gateways/web/EShopOnAbp.WebGateway.sln new file mode 100644 index 00000000..cd83a8dd --- /dev/null +++ b/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 diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs b/gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs new file mode 100644 index 00000000..6ddeb9bc --- /dev/null +++ b/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"); + } + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj new file mode 100644 index 00000000..d3af9924 --- /dev/null +++ b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj @@ -0,0 +1,22 @@ + + + + net5.0 + + + + + + + + + + + + + + + + + + diff --git a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs new file mode 100644 index 00000000..a87c0bc4 --- /dev/null +++ b/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 /* 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(); + 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(); + } + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Program.cs b/gateways/web/src/EShopOnAbp.WebGateway/Program.cs new file mode 100644 index 00000000..b8a0b11b --- /dev/null +++ b/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 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(); }) + .UseAutofac() + .UseSerilog(); + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Properties/launchSettings.json b/gateways/web/src/EShopOnAbp.WebGateway/Properties/launchSettings.json new file mode 100644 index 00000000..e0e5c0b3 --- /dev/null +++ b/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" + } + } + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Startup.cs b/gateways/web/src/EShopOnAbp.WebGateway/Startup.cs new file mode 100644 index 00000000..3f299188 --- /dev/null +++ b/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(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.InitializeApplication(); + } + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/appsettings.Development.json b/gateways/web/src/EShopOnAbp.WebGateway/appsettings.Development.json new file mode 100644 index 00000000..8983e0fc --- /dev/null +++ b/gateways/web/src/EShopOnAbp.WebGateway/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json b/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json new file mode 100644 index 00000000..92d5717d --- /dev/null +++ b/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" + } +} diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json index 6fd8eda8..d39a076b 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json +++ b/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"