diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json b/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json index 20b0b62f..290fc0f6 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json +++ b/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json @@ -14,7 +14,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "AccountService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "AllowedHosts": "*", diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs index 95ca4f5c..33d9554e 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs @@ -24,7 +24,21 @@ namespace EShopOnAbp.WebPublicGateway var configuration = context.Services.GetConfiguration(); var hostingEnvironment = context.Services.GetHostingEnvironment(); - SwaggerConfigurationHelper.Configure(context, "WebPublic Gateway"); + SwaggerWithAuthConfigurationHelper.Configure( + context: context, + authority: configuration["AuthServer:Authority"], + scopes: new Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + { "AccountService", "Account Service API" }, + { "IdentityService", "Identity Service API" }, + { "AdministrationService", "Administration Service API" }, + { "CatalogService", "Catalog Service API" }, + { "BasketService", "Basket Service API" }, + { "PaymentService", "Payment Service API" }, + { "OrderingService", "Ordering Service API" }, + }, + apiTitle: "WebPublic Gateway" + ); } public override void OnApplicationInitialization(ApplicationInitializationContext context) @@ -59,12 +73,8 @@ namespace EShopOnAbp.WebPublicGateway } options.SwaggerEndpoint($"{url}/swagger/v1/swagger.json", $"{config.ServiceKey} API"); - // options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); - // options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); - - // TODO: Find a way to get these configurations from related running applications settings. - // options.OAuthClientId($"{config.ServiceKey.Replace(" ","")}_Swagger"); - // options.OAuthClientSecret("1q2w3e*"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); } }); app.MapWhen( diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json index 39f6f0a0..1eee0654 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json @@ -5,7 +5,9 @@ }, "AuthServer": { "Authority": "https://localhost:44330", - "RequireHttpsMetadata": "true" + "RequireHttpsMetadata": "true", + "SwaggerClientId": "WebGateway_Swagger", + "SwaggerClientSecret": "1q2w3e*" }, "Logging": { "LogLevel": { diff --git a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs index b933506b..34bfa808 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs +++ b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs @@ -24,7 +24,22 @@ namespace EShopOnAbp.WebGateway { var configuration = context.Services.GetConfiguration(); var hostingEnvironment = context.Services.GetHostingEnvironment(); - SwaggerConfigurationHelper.Configure(context, "Web Gateway"); + + SwaggerWithAuthConfigurationHelper.Configure( + context: context, + authority: configuration["AuthServer:Authority"], + scopes: new Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + { "AccountService", "Account Service API" }, + { "IdentityService", "Identity Service API" }, + { "AdministrationService", "Administration Service API" }, + { "CatalogService", "Catalog Service API" }, + { "BasketService", "Basket Service API" }, + { "PaymentService", "Payment Service API" }, + { "OrderingService", "Ordering Service API" }, + }, + apiTitle: "Web Gateway" + ); context.Services.AddCors(options => { diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs index c87c1594..6c33cb8d 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs @@ -7,6 +7,7 @@ using EShopOnAbp.Shared.Hosting.AspNetCore; using EShopOnAbp.Shared.Hosting.Microservices; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; @@ -34,14 +35,13 @@ namespace EShopOnAbp.AdministrationService var configuration = context.Services.GetConfiguration(); JwtBearerConfigurationHelper.Configure(context, "AdministrationService"); - // SwaggerConfigurationHelper.Configure(context, "Administration Service API"); SwaggerWithAuthConfigurationHelper.Configure( context: context, authority: configuration["AuthServer:Authority"], scopes: new Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ { - {"Administration", "Administration Service API"}, + {"AdministrationService", "Administration Service API"}, }, apiTitle: "Administration Service API" ); @@ -87,7 +87,10 @@ namespace EShopOnAbp.AdministrationService app.UseSwagger(); app.UseSwaggerUI(options => { + var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/appsettings.json b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/appsettings.json index 19c9900c..8610b450 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/appsettings.json +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "AdministrationService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "RemoteServices": { diff --git a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json index 5168b4bf..2e9949c5 100644 --- a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json +++ b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "BasketService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "RemoteServices": { diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json index ed868ed2..7b5799db 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "CatalogService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "Logging": { diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs index 44e5a01f..415c2304 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs @@ -8,6 +8,7 @@ using EShopOnAbp.Shared.Hosting.Gateways; using EShopOnAbp.Shared.Hosting.Microservices; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; @@ -32,7 +33,17 @@ namespace EShopOnAbp.IdentityService var hostingEnvironment = context.Services.GetHostingEnvironment(); JwtBearerConfigurationHelper.Configure(context, "IdentityService"); - // SwaggerConfigurationHelper.Configure(context, "Identity Service API"); + + 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"} + }, + apiTitle: "IdentityService Gateway API" + ); + context.Services.AddCors(options => { options.AddDefaultPolicy(builder => @@ -51,16 +62,6 @@ namespace EShopOnAbp.IdentityService .AllowCredentials(); }); }); - - 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"} - }, - apiTitle: "IdentityService Gateway API" - ); } public override void OnApplicationInitialization(ApplicationInitializationContext context) @@ -85,7 +86,10 @@ namespace EShopOnAbp.IdentityService app.UseSwagger(); app.UseSwaggerUI(options => { + var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json index 93d8616f..8f53f8ad 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "IdentityService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "Logging": { diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json index b83b13d0..c3fabcdc 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "OrderingService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "Logging": { diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json index acec763a..83d05c81 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json @@ -6,7 +6,7 @@ "AuthServer": { "Authority": "https://localhost:44330", "RequireHttpsMetadata": "true", - "SwaggerClientId": "PaymentService_Swagger", + "SwaggerClientId": "WebGateway_Swagger", "SwaggerClientSecret": "1q2w3e*" }, "Logging": {