diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json index 60ed6166..e1e08219 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json @@ -7,7 +7,7 @@ "AuthServer": { "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "true", - "SwaggerClientId": "WebGateway_Swagger", + "SwaggerClientId": "SwaggerClient", "SwaggerClientSecret": "1q2w3e*" }, "Logging": { diff --git a/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json b/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json index 00dde9fb..487b5e11 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json +++ b/gateways/web/src/EShopOnAbp.WebGateway/appsettings.json @@ -8,7 +8,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "true", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Logging": { "LogLevel": { diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs index bc61eb04..d823f511 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs @@ -59,17 +59,11 @@ public override void ConfigureServices(ServiceConfigurationContext context) .AllowCredentials(); }); }); - - Configure(options => - { - options.IsDynamicPermissionStoreEnabled = true; - }); - Configure(options => - { - options.IsDynamicSettingStoreEnabled = true; - }); - + Configure(options => { options.IsDynamicPermissionStoreEnabled = true; }); + + Configure(options => { options.IsDynamicSettingStoreEnabled = true; }); + // Configure(options => // { // options.ValueProviders.Clear(); @@ -99,7 +93,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseUnitOfWork(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API"); diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs index 92adfd78..29c769df 100644 --- a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs @@ -95,7 +95,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); diff --git a/services/basket/src/EShopOnAbp.BasketService/appsettings.json b/services/basket/src/EShopOnAbp.BasketService/appsettings.json index 848af7b7..e1922980 100644 --- a/services/basket/src/EShopOnAbp.BasketService/appsettings.json +++ b/services/basket/src/EShopOnAbp.BasketService/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "RemoteServices": { "Catalog": { diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs index 410e55aa..cd0e3cba 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs @@ -101,7 +101,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API"); diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json index a36a8c76..9fdb84ca 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Logging": { "LogLevel": { diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs index 120af667..9a21f3ae 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs @@ -111,7 +111,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Cmskit Service API"); diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/appsettings.json b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/appsettings.json index 1d6763a6..3590e555 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/appsettings.json +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Logging": { "LogLevel": { diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj index df7b860b..03de9037 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj @@ -3,6 +3,7 @@ net8.0 EShopOnAbp.IdentityService + true diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs index 66bd0070..489741fe 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs @@ -22,8 +22,7 @@ namespace EShopOnAbp.IdentityService; typeof(EShopOnAbpSharedHostingMicroservicesModule), typeof(IdentityServiceHttpApiModule), typeof(IdentityServiceApplicationModule), - typeof(IdentityServiceEntityFrameworkCoreModule), - typeof(EShopOnAbpSharedHostingGatewaysModule) + typeof(IdentityServiceEntityFrameworkCoreModule) )] public class IdentityServiceHttpApiHostModule : AbpModule { @@ -91,7 +90,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json index 8b7c19da..fe016048 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Keycloak": { "url": "http://localhost:8080", diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs index be9910c9..1ba22f30 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs @@ -88,7 +88,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API"); diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json index aa730d23..d15531c8 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Logging": { "LogLevel": { diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs index 953d02cf..59767643 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs @@ -81,7 +81,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API"); diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json index 0962ca7e..7624b30e 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json @@ -7,7 +7,7 @@ "Authority": "http://localhost:8080/realms/master", "RequireHttpsMetadata": "false", "MetadataAddress": "http://localhost:8080/realms/master", - "SwaggerClientId": "WebGateway_Swagger" + "SwaggerClientId": "SwaggerClient" }, "Logging": { "LogLevel": { diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs new file mode 100644 index 00000000..0cf25f81 --- /dev/null +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs @@ -0,0 +1,27 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Swashbuckle.AspNetCore.SwaggerUI; +using Volo.Abp.Swashbuckle; + +namespace EShopOnAbp.Shared.Hosting.AspNetCore; + +public static class AbpSwaggerUIBuilderExtensions +{ + public static IApplicationBuilder UseAbpSwaggerWithCustomScriptUI( + this IApplicationBuilder app, + Action? setupAction = null) + { + var resolver = app.ApplicationServices.GetService(); + + return app.UseSwaggerUI(options => + { + options.InjectJavascript("ui/abp.js"); + options.InjectJavascript("ui/abp.swagger.js"); + options.InjectJavascript("ui/requestinterceptor.js"); + options.IndexStream = () => resolver?.Resolver(); + + setupAction?.Invoke(options); + }); + } +} \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj index 65802e99..af2061f5 100644 --- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj @@ -17,4 +17,19 @@ + + + + + + + true + PreserveNewest + + + + + + + diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs index 0c71d886..12f54210 100644 --- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs @@ -1,6 +1,7 @@ using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Modularity; using Volo.Abp.Swashbuckle; +using Volo.Abp.VirtualFileSystem; namespace EShopOnAbp.Shared.Hosting.AspNetCore; @@ -14,5 +15,9 @@ public class EShopOnAbpSharedHostingAspNetCoreModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { + Configure(options => + { + options.FileSets.AddEmbedded("EShopOnAbp.Shared.Hosting.AspNetCore"); + }); } } \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/wwwroot/swagger/ui/requestinterceptor.js b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs index ad54e1da..9dab2860 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -15,7 +16,7 @@ public static IApplicationBuilder UseSwaggerUIWithYarp(this IApplicationBuilder ApplicationInitializationContext context) { app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); var logger = context.ServiceProvider.GetRequiredService>();