Browse Source
Merge pull request #238 from abpframework/gterdem/swagger_fix
eShopOnAbp: Keycloak swagger authorization
pull/244/head
maliming
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with
79 additions and
28 deletions
-
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.json
-
gateways/web/src/EShopOnAbp.WebGateway/appsettings.json
-
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs
-
services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs
-
services/basket/src/EShopOnAbp.BasketService/appsettings.json
-
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs
-
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json
-
services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs
-
services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/appsettings.json
-
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj
-
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs
-
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json
-
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs
-
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json
-
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs
-
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json
-
shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs
-
shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
-
shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs
-
shared/EShopOnAbp.Shared.Hosting.AspNetCore/wwwroot/swagger/ui/requestinterceptor.js
-
shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs
|
|
|
@ -7,7 +7,7 @@ |
|
|
|
"AuthServer": { |
|
|
|
"Authority": "http://localhost:8080/realms/master", |
|
|
|
"RequireHttpsMetadata": "true", |
|
|
|
"SwaggerClientId": "WebGateway_Swagger", |
|
|
|
"SwaggerClientId": "SwaggerClient", |
|
|
|
"SwaggerClientSecret": "1q2w3e*" |
|
|
|
}, |
|
|
|
"Logging": { |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -59,17 +59,11 @@ public class AdministrationServiceHttpApiHostModule : AbpModule |
|
|
|
.AllowCredentials(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
Configure<PermissionManagementOptions>(options => |
|
|
|
{ |
|
|
|
options.IsDynamicPermissionStoreEnabled = true; |
|
|
|
}); |
|
|
|
|
|
|
|
Configure<SettingManagementOptions>(options => |
|
|
|
{ |
|
|
|
options.IsDynamicSettingStoreEnabled = true; |
|
|
|
}); |
|
|
|
|
|
|
|
Configure<PermissionManagementOptions>(options => { options.IsDynamicPermissionStoreEnabled = true; }); |
|
|
|
|
|
|
|
Configure<SettingManagementOptions>(options => { options.IsDynamicSettingStoreEnabled = true; }); |
|
|
|
|
|
|
|
// Configure<AbpPermissionOptions>(options =>
|
|
|
|
// {
|
|
|
|
// options.ValueProviders.Clear();
|
|
|
|
@ -99,7 +93,7 @@ public class AdministrationServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseUnitOfWork(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API"); |
|
|
|
|
|
|
|
@ -95,7 +95,7 @@ public class BasketServiceModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ public class CatalogServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API"); |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ public class CmskitServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Cmskit Service API"); |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -3,6 +3,7 @@ |
|
|
|
<PropertyGroup> |
|
|
|
<TargetFramework>net8.0</TargetFramework> |
|
|
|
<RootNamespace>EShopOnAbp.IdentityService</RootNamespace> |
|
|
|
<PreserveCompilationReferences>true</PreserveCompilationReferences> |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
|
|
|
|
@ -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 class IdentityServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); |
|
|
|
|
|
|
|
@ -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", |
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ public class OrderingServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API"); |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -81,7 +81,7 @@ public class PaymentServiceHttpApiHostModule : AbpModule |
|
|
|
app.UseAbpClaimsMap(); |
|
|
|
app.UseAuthorization(); |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API"); |
|
|
|
|
|
|
|
@ -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": { |
|
|
|
|
|
|
|
@ -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<SwaggerUIOptions>? setupAction = null) |
|
|
|
{ |
|
|
|
var resolver = app.ApplicationServices.GetService<ISwaggerHtmlResolver>(); |
|
|
|
|
|
|
|
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); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -17,4 +17,19 @@ |
|
|
|
<ProjectReference Include="..\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<None Remove="wwwroot\swagger\ui\requestinterceptor.js" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<Content Include="wwwroot\swagger\ui\requestinterceptor.js"> |
|
|
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
|
|
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|
|
|
</Content> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<EmbeddedResource Include="wwwroot\swagger\ui\requestinterceptor.js" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
</Project> |
|
|
|
|
|
|
|
@ -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<AbpVirtualFileSystemOptions>(options => |
|
|
|
{ |
|
|
|
options.FileSets.AddEmbedded<EShopOnAbpSharedHostingAspNetCoreModule>("EShopOnAbp.Shared.Hosting.AspNetCore"); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -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); |
|
|
|
}; |
|
|
|
@ -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 class YarpSwaggerUIBuilderExtensions |
|
|
|
ApplicationInitializationContext context) |
|
|
|
{ |
|
|
|
app.UseSwagger(); |
|
|
|
app.UseAbpSwaggerUI(options => |
|
|
|
app.UseAbpSwaggerWithCustomScriptUI(options => |
|
|
|
{ |
|
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); |
|
|
|
var logger = context.ServiceProvider.GetRequiredService<ILogger<ApplicationInitializationContext>>(); |
|
|
|
|