diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs index 95f4e574..e8c43e61 100644 --- a/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs +++ b/apps/auth-server/src/EShopOnAbp.AuthServer/EShopOnAbpAuthServerModule.cs @@ -200,6 +200,8 @@ namespace EShopOnAbp.AuthServer app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Account Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); }); app.UseAuditing(); app.UseConfiguredEndpoints(endpoints => diff --git a/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json b/apps/auth-server/src/EShopOnAbp.AuthServer/appsettings.json index 775b5032..20b0b62f 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:44351,https://localhost:44353,https://localhost:44356,https://localhost:44372,https://localhost:44373,http://localhost:4200", + "CorsOrigins": "https://*.EShopOnAbp.com,http://localhost:4200,https://localhost:44307,https://localhost:44351,https://localhost:44353,https://localhost:44354,https://localhost:44355,https://localhost:44356,https://localhost:44357,https://localhost:44372,https://localhost:44373,http://localhost:4200", "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" }, "Logging": { diff --git a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs index ff161276..1d6d2665 100644 --- a/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Configuration; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.AntiForgery; @@ -24,20 +25,22 @@ namespace EShopOnAbp.BasketService public override void ConfigureServices(ServiceConfigurationContext context) { Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true; - + var configuration = context.Services.GetConfiguration(); var hostingEnvironment = context.Services.GetHostingEnvironment(); - JwtBearerConfigurationHelper.Configure(context, "AdministrationService"); //TODO: Should be "BasketService", but didn't work :( + JwtBearerConfigurationHelper.Configure(context, + "AdministrationService"); //TODO: Should be "BasketService", but didn't work :( // SwaggerConfigurationHelper.Configure(context, "Basket 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 */ - { - {"BasketService", "Catalog Service API"}, - }, + scopes: new + Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + {"BasketService", "Catalog Service API"}, + }, apiTitle: "Basket Service API" ); @@ -59,7 +62,7 @@ namespace EShopOnAbp.BasketService .AllowCredentials(); }); }); - + Configure(options => { options.ConventionalControllers.Create( @@ -69,11 +72,8 @@ namespace EShopOnAbp.BasketService opts.RemoteServiceName = "Basket"; }); }); - - Configure(options => - { - options.AutoValidate = false; - }); + + Configure(options => { options.AutoValidate = false; }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) @@ -96,7 +96,13 @@ namespace EShopOnAbp.BasketService app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); }); + app.UseSwaggerUI(options => + { + var configuration = context.ServiceProvider.GetRequiredService(); + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); @@ -106,4 +112,4 @@ namespace EShopOnAbp.BasketService }); } } -} +} \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs index 0cc34569..10579704 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs @@ -9,10 +9,10 @@ using System; using System.Collections.Generic; using System.Linq; using EShopOnAbp.CatalogService.MongoDB; +using Microsoft.Extensions.Configuration; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.AntiForgery; -using Volo.Abp.AspNetCore.Uow; using Volo.Abp.Modularity; using Volo.Abp.Threading; using Volo.Abp.Uow; @@ -31,7 +31,7 @@ namespace EShopOnAbp.CatalogService { var configuration = context.Services.GetConfiguration(); - JwtBearerConfigurationHelper.Configure(context, "AdministrationService"); //TODO: Should be "CatalogService", but didn't work :( + JwtBearerConfigurationHelper.Configure(context, "CatalogService"); //TODO: Should be "CatalogService", but didn't work :( // SwaggerConfigurationHelper.Configure(context, "Catalog Service API"); SwaggerWithAuthConfigurationHelper.Configure( @@ -104,7 +104,13 @@ namespace EShopOnAbp.CatalogService app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API"); }); + app.UseSwaggerUI(options => + { + var configuration = context.ServiceProvider.GetRequiredService(); + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs index 3d0f5eea..f8c8a419 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Configuration; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; @@ -92,7 +93,14 @@ namespace EShopOnAbp.OrderingService app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API"); }); + app.UseSwaggerUI(options => + { + var configuration = context.ServiceProvider.GetRequiredService(); + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + + }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork(); diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs index 9eed0e02..5600ec82 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Configuration; using Volo.Abp; using Volo.Abp.Modularity; using Volo.Abp.Threading; @@ -84,7 +85,13 @@ namespace EShopOnAbp.PaymentService app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API"); }); + app.UseSwaggerUI(options => + { + var configuration = context.ServiceProvider.GetRequiredService(); + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + }); app.UseAbpSerilogEnrichers(); app.UseAuditing(); app.UseUnitOfWork();