Compare commits

...

3 Commits

Author SHA1 Message Date
Galip Tolga Erdem a6fd7060f1 Updated gateways to use oidc for swagger 3 years ago
Galip Tolga Erdem 09b5bb62b5 Updated yarp configurations 3 years ago
Galip Tolga Erdem df2386e970 Updated swagger config and gateway hosting 3 years ago
  1. 32
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs
  2. 52
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Docker.json
  3. 113
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Staging.json
  4. 44
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.json
  5. 32
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs
  6. 64
      gateways/web/src/EShopOnAbp.WebGateway/appsettings.Docker.json
  7. 65
      gateways/web/src/EShopOnAbp.WebGateway/yarp.json
  8. 2
      shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj
  9. 24
      shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs
  10. 2
      shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj
  11. 31
      shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs

32
gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs

@ -21,25 +21,19 @@ public class EShopOnAbpWebPublicGatewayModule : AbpModule
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerConfigurationHelper.ConfigureWithAuth( SwaggerConfigurationHelper
context: context, .ConfigureWithOidc(
authority: configuration["AuthServer:Authority"], context: context,
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */ authority: configuration["AuthServer:Authority"]!,
{ /* Requested scopes for authorization code request and descriptions for swagger UI only */
{ "AccountService", "Account Service API" }, scopes: new[]
{ "IdentityService", "Identity Service API" }, {
{ "AdministrationService", "Administration Service API" }, "AccountService", "IdentityService", "AdministrationService", "CatalogService", "BasketService",
{ "CatalogService", "Catalog Service API" }, "OrderingService", "CmskitService"
{ "BasketService", "Basket Service API" }, },
{ "PaymentService", "Payment Service API" }, apiTitle: "Public Web Gateway API",
{ "OrderingService", "Ordering Service API" }, discoveryEndpoint: configuration["AuthServer:MetadataAddress"]
{ "CmskitService", "Cmskit Service API" }, );
},
apiTitle: "WebPublic Gateway"
);
// context.Services.AddReverseProxy()
// .LoadFromConfig(configuration.GetSection("ReverseProxy"));
} }
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)

52
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Docker.json

@ -1,50 +1,62 @@
{ {
"ReverseProxy": { "ReverseProxy": {
"Routes": { "Routes": {
"Account Service": { "AbpApi": {
"ClusterId": "accountCluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/account/{**everything}" "Path": "/api/abp/{**catch-all}"
} }
}, },
"Administration Service": { "Account Service": {
"ClusterId": "administrationCluster", "ClusterId": "Account",
"Match": { "Match": {
"Path": "/api/abp/{**everything}" "Path": "/api/account/{**everything}"
} }
}, },
"Catalog Service": { "Catalog Service": {
"ClusterId": "catalogCluster", "ClusterId": "Catalog",
"Match": { "Match": {
"Path": "/api/catalog/{**everything}" "Path": "/api/catalog/{**everything}"
} }
}, },
"Basket Service": { "Basket Service": {
"ClusterId": "basketCluster", "ClusterId": "Basket",
"Match": { "Match": {
"Path": "/api/basket/{**everything}" "Path": "/api/basket/{**everything}"
} }
}, },
"Ordering Service": { "Ordering Service": {
"ClusterId": "orderingCluster", "ClusterId": "Ordering",
"Match": { "Match": {
"Path": "/api/ordering/{**everything}" "Path": "/api/ordering/{**everything}"
} }
}, },
"Payment Service": { "Payment Service": {
"ClusterId": "paymentCluster", "ClusterId": "Payment",
"Match": { "Match": {
"Path": "/api/payment/{**everything}" "Path": "/api/payment/{**everything}"
} }
}, },
"Cmskit Service": { "Cmskit Service": {
"ClusterId": "cmskitCluster", "ClusterId": "CmsKit",
"Match": { "Match": {
"Path": "/api/cmskit/{**everything}" "Path": "/api/cmskit/{**everything}"
} }
}, },
"Cmskit Public Service": {
"ClusterId": "CmsKit",
"Match": {
"Path": "/api/cms-kit-public/{**everything}"
}
},
"Cmskit Admin Service": {
"ClusterId": "CmsKit",
"Match": {
"Path": "/api/cms-kit-admin/{**everything}"
}
},
"product-picture-route": { "product-picture-route": {
"ClusterId": "productPictureCluster", "ClusterId": "ProductPictures",
"Match": { "Match": {
"Path": "/product-images/{**everything}", "Path": "/product-images/{**everything}",
"Methods": [ "GET" ] "Methods": [ "GET" ]
@ -52,56 +64,56 @@
} }
}, },
"Clusters": { "Clusters": {
"accountCluster": { "Account": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://app-authserver" "Address": "http://app-authserver"
} }
} }
}, },
"administrationCluster": { "Administration": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://administration-service" "Address": "http://administration-service"
} }
} }
}, },
"catalogCluster": { "Catalog": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://catalog-service" "Address": "http://catalog-service"
} }
} }
}, },
"basketCluster": { "Basket": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://basket-service" "Address": "http://basket-service"
} }
} }
}, },
"orderingCluster": { "Ordering": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://ordering-service" "Address": "http://ordering-service"
} }
} }
}, },
"paymentCluster": { "Payment": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://payment-service" "Address": "http://payment-service"
} }
} }
}, },
"cmskitCluster": { "CmsKit": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://cmskit-service" "Address": "http://cmskit-service"
} }
} }
}, },
"productPictureCluster": { "ProductPictures": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://catalog-service" "Address": "http://catalog-service"

113
gateways/web-public/src/EShopOnAbp.WebPublicGateway/appsettings.Staging.json

@ -1,113 +0,0 @@
{
"ReverseProxy": {
"Routes": {
"Account Service": {
"ClusterId": "accountCluster",
"Match": {
"Path": "/api/account/{**everything}"
}
},
"Administration Service": {
"ClusterId": "administrationCluster",
"Match": {
"Path": "/api/abp/{**everything}"
}
},
"Catalog Service": {
"ClusterId": "catalogCluster",
"Match": {
"Path": "/api/catalog/{**everything}"
}
},
"Basket Service": {
"ClusterId": "basketCluster",
"Match": {
"Path": "/api/basket/{**everything}"
}
},
"Ordering Service": {
"ClusterId": "orderingCluster",
"Match": {
"Path": "/api/ordering/{**everything}"
}
},
"Payment Service": {
"ClusterId": "paymentCluster",
"Match": {
"Path": "/api/payment/{**everything}"
}
},
"Cmskit Service": {
"ClusterId": "cmskitCluster",
"Match": {
"Path": "/api/cmskit/{**everything}"
}
},
"product-picture-route": {
"ClusterId": "productPictureCluster",
"Match": {
"Path": "/product-images/{**everything}",
"Methods": [ "GET" ]
}
}
},
"Clusters": {
"accountCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-authserver"
}
}
},
"administrationCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-administration"
}
}
},
"catalogCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-catalog"
}
}
},
"basketCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-basket"
}
}
},
"orderingCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-ordering"
}
}
},
"paymentCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-payment"
}
}
},
"cmskitCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-cmskit"
}
}
},
"productPictureCluster": {
"Destinations": {
"destination1": {
"Address": "http://eshop-st-catalog"
}
}
}
}
}
}

44
gateways/web-public/src/EShopOnAbp.WebPublicGateway/yarp.json

@ -1,62 +1,62 @@
{ {
"ReverseProxy": { "ReverseProxy": {
"Routes": { "Routes": {
"Account Service": { "AbpApi": {
"ClusterId": "accountCluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/account/{**everything}" "Path": "/api/abp/{**catch-all}"
} }
}, },
"Administration Service": { "Account Service": {
"ClusterId": "administrationCluster", "ClusterId": "Account",
"Match": { "Match": {
"Path": "/api/abp/{**everything}" "Path": "/api/account/{**everything}"
} }
}, },
"Catalog Service": { "Catalog Service": {
"ClusterId": "catalogCluster", "ClusterId": "Catalog",
"Match": { "Match": {
"Path": "/api/catalog/{**everything}" "Path": "/api/catalog/{**everything}"
} }
}, },
"Basket Service": { "Basket Service": {
"ClusterId": "basketCluster", "ClusterId": "Basket",
"Match": { "Match": {
"Path": "/api/basket/{**everything}" "Path": "/api/basket/{**everything}"
} }
}, },
"Ordering Service": { "Ordering Service": {
"ClusterId": "orderingCluster", "ClusterId": "Ordering",
"Match": { "Match": {
"Path": "/api/ordering/{**everything}" "Path": "/api/ordering/{**everything}"
} }
}, },
"Payment Service": { "Payment Service": {
"ClusterId": "paymentCluster", "ClusterId": "Payment",
"Match": { "Match": {
"Path": "/api/payment/{**everything}" "Path": "/api/payment/{**everything}"
} }
}, },
"Cmskit Service": { "Cmskit Service": {
"ClusterId": "cmskitCluster", "ClusterId": "CmsKit",
"Match": { "Match": {
"Path": "/api/cmskit/{**everything}" "Path": "/api/cmskit/{**everything}"
} }
}, },
"Cmskit Public Service": { "Cmskit Public Service": {
"ClusterId": "cmskitCluster", "ClusterId": "CmsKit",
"Match": { "Match": {
"Path": "/api/cms-kit-public/{**everything}" "Path": "/api/cms-kit-public/{**everything}"
} }
}, },
"Cmskit Admin Service": { "Cmskit Admin Service": {
"ClusterId": "cmskitCluster", "ClusterId": "CmsKit",
"Match": { "Match": {
"Path": "/api/cms-kit-admin/{**everything}" "Path": "/api/cms-kit-admin/{**everything}"
} }
}, },
"product-picture-route": { "product-picture-route": {
"ClusterId": "productPictureCluster", "ClusterId": "ProductPictures",
"Match": { "Match": {
"Path": "/product-images/{**everything}", "Path": "/product-images/{**everything}",
"Methods": [ "GET" ] "Methods": [ "GET" ]
@ -64,56 +64,56 @@
} }
}, },
"Clusters": { "Clusters": {
"accountCluster": { "Account": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44330" "Address": "https://localhost:44330"
} }
} }
}, },
"administrationCluster": { "Administration": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44353" "Address": "https://localhost:44353"
} }
} }
}, },
"catalogCluster": { "Catalog": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44354" "Address": "https://localhost:44354"
} }
} }
}, },
"basketCluster": { "Basket": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44355" "Address": "https://localhost:44355"
} }
} }
}, },
"orderingCluster": { "Ordering": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44356" "Address": "https://localhost:44356"
} }
} }
}, },
"paymentCluster": { "Payment": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44357" "Address": "https://localhost:44357"
} }
} }
}, },
"cmskitCluster": { "CmsKit": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44358" "Address": "https://localhost:44358"
} }
} }
}, },
"productPictureCluster": { "ProductPictures": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44354" "Address": "https://localhost:44354"

32
gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs

@ -23,23 +23,19 @@ public class EShopOnAbpWebGatewayModule : AbpModule
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment(); var hostingEnvironment = context.Services.GetHostingEnvironment();
SwaggerConfigurationHelper.ConfigureWithAuth( SwaggerConfigurationHelper
context: context, .ConfigureWithOidc(
authority: configuration["AuthServer:Authority"], context: context,
scopes: new authority: configuration["AuthServer:Authority"]!,
Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */ /* Requested scopes for authorization code request and descriptions for swagger UI only */
scopes: new[]
{ {
{"AccountService", "Account Service API"}, "AccountService", "IdentityService", "AdministrationService", "CatalogService", "BasketService",
{"IdentityService", "Identity Service API"}, "PaymentService", "OrderingService", "CmskitService"
{"AdministrationService", "Administration Service API"},
{"CatalogService", "Catalog Service API"},
{"BasketService", "Basket Service API"},
{"PaymentService", "Payment Service API"},
{"OrderingService", "Ordering Service API"},
{"CmskitService", "Cmskit Service API"},
}, },
apiTitle: "Web Gateway" apiTitle: "Web Gateway",
); discoveryEndpoint: configuration["AuthServer:MetadataAddress"]
);
context.Services.AddCors(options => context.Services.AddCors(options =>
{ {
@ -70,6 +66,7 @@ public class EShopOnAbpWebGatewayModule : AbpModule
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
app.UseCorrelationId(); app.UseCorrelationId();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseCors(); app.UseCors();
@ -80,9 +77,6 @@ public class EShopOnAbpWebGatewayModule : AbpModule
.AddRedirect("^(|\\|\\s+)$", "/swagger")); .AddRedirect("^(|\\|\\s+)$", "/swagger"));
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints => { endpoints.MapReverseProxy(); });
{
endpoints.MapReverseProxy();
});
} }
} }

64
gateways/web/src/EShopOnAbp.WebGateway/appsettings.Docker.json

@ -1,6 +1,12 @@
{ {
"ReverseProxy": { "ReverseProxy": {
"Routes": { "Routes": {
"AbpApi": {
"ClusterId": "Administration",
"Match": {
"Path": "/api/abp/{**catch-all}"
}
},
"Account Service": { "Account Service": {
"ClusterId": "accountCluster", "ClusterId": "accountCluster",
"Match": { "Match": {
@ -8,79 +14,91 @@
} }
}, },
"Identity Service": { "Identity Service": {
"ClusterId": "identityCluster", "ClusterId": "Identity",
"Match": { "Match": {
"Path": "/api/identity/{**everything}" "Path": "/api/identity/{**everything}"
} }
}, },
"Administration Service": { "FeatureManagement": {
"ClusterId": "administrationCluster", "ClusterId": "Administration",
"Match": {
"Path": "/api/abp/{**everything}"
}
},
"feature-management-route": {
"ClusterId": "featureManagementCluster",
"Match": { "Match": {
"Path": "/api/feature-management/{**everything}" "Path": "/api/feature-management/{**everything}"
} }
}, },
"permission-management-route": { "PermissionManagement": {
"ClusterId": "permissionManagementCluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/permission-management/{**everything}" "Path": "/api/permission-management/{**everything}"
} }
}, },
"setting-management-route": { "SettingManagement": {
"ClusterId": "settingManagementCluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/setting-management/{**everything}" "Path": "/api/setting-management/{**everything}"
} }
},
"Catalog Service": {
"ClusterId": "Catalog",
"Match": {
"Path": "/api/catalog/{**everything}"
}
},
"Ordering Service": {
"ClusterId": "Ordering",
"Match": {
"Path": "/api/ordering/{**everything}"
}
},
"Cmskit Service": {
"ClusterId": "CmsKit",
"Match": {
"Path": "/api/cmskit/{**everything}"
}
} }
}, },
"Clusters": { "Clusters": {
"accountCluster": { "Account": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://app-authserver" "Address": "http://app-authserver"
} }
} }
}, },
"identityCluster": { "Identity": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://identity-service" "Address": "http://identity-service"
} }
} }
}, },
"administrationCluster": { "Administration": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://administration-service" "Address": "http://administration-service"
} }
} }
}, },
"featureManagementCluster": { "Catalog": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://administration-service" "Address": "http://catalog-service"
} }
} }
}, },
"permissionManagementCluster": { "Ordering": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://administration-service" "Address": "http://ordering-service"
} }
} }
}, },
"settingManagementCluster": { "CmsKit": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "http://administration-service" "Address": "http://cmskit-service"
} }
} }
} },
} }
} }
} }

65
gateways/web/src/EShopOnAbp.WebGateway/yarp.json

@ -1,6 +1,12 @@
{ {
"ReverseProxy": { "ReverseProxy": {
"Routes": { "Routes": {
"AbpApi": {
"ClusterId": "Administration",
"Match": {
"Path": "/api/abp/{**catch-all}"
}
},
"Account Service": { "Account Service": {
"ClusterId": "accountCluster", "ClusterId": "accountCluster",
"Match": { "Match": {
@ -8,112 +14,85 @@
} }
}, },
"Identity Service": { "Identity Service": {
"ClusterId": "identityCluster", "ClusterId": "Identity",
"Match": { "Match": {
"Path": "/api/identity/{**everything}" "Path": "/api/identity/{**everything}"
} }
}, },
"Administration Service": { "FeatureManagement": {
"ClusterId": "administrationCluster", "ClusterId": "Administration",
"Match": {
"Path": "/api/abp/{**everything}"
}
},
"feature-management-route": {
"ClusterId": "feature-management-cluster",
"Match": { "Match": {
"Path": "/api/feature-management/{**everything}" "Path": "/api/feature-management/{**everything}"
} }
}, },
"permission-management-route": { "PermissionManagement": {
"ClusterId": "permission-management-cluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/permission-management/{**everything}" "Path": "/api/permission-management/{**everything}"
} }
}, },
"setting-management-route": { "SettingManagement": {
"ClusterId": "setting-management-cluster", "ClusterId": "Administration",
"Match": { "Match": {
"Path": "/api/setting-management/{**everything}" "Path": "/api/setting-management/{**everything}"
} }
}, },
"Catalog Service": { "Catalog Service": {
"ClusterId": "catalogCluster", "ClusterId": "Catalog",
"Match": { "Match": {
"Path": "/api/catalog/{**everything}" "Path": "/api/catalog/{**everything}"
} }
}, },
"Ordering Service": { "Ordering Service": {
"ClusterId": "orderingCluster", "ClusterId": "Ordering",
"Match": { "Match": {
"Path": "/api/ordering/{**everything}" "Path": "/api/ordering/{**everything}"
} }
}, },
"Cmskit Service": { "Cmskit Service": {
"ClusterId": "cmskitCluster", "ClusterId": "CmsKit",
"Match": { "Match": {
"Path": "/api/cmskit/{**everything}" "Path": "/api/cmskit/{**everything}"
} }
} }
}, },
"Clusters": { "Clusters": {
"accountCluster": { "Account": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44330" "Address": "https://localhost:44330"
} }
} }
}, },
"identityCluster": { "Identity": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44351" "Address": "https://localhost:44351"
} }
} }
}, },
"administrationCluster": { "Administration": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44353"
}
}
},
"feature-management-cluster": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44353"
}
}
},
"permission-management-cluster": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44353"
}
}
},
"setting-management-cluster": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44353" "Address": "https://localhost:44353"
} }
} }
}, },
"catalogCluster": { "Catalog": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44354" "Address": "https://localhost:44354"
} }
} }
}, },
"orderingCluster": { "Ordering": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44356" "Address": "https://localhost:44356"
} }
} }
}, },
"cmskitCluster": { "CmsKit": {
"Destinations": { "Destinations": {
"destination1": { "destination1": {
"Address": "https://localhost:44358" "Address": "https://localhost:44358"

2
shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj

@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.0.0" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.0.0" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="7.0.0" /> <PackageReference Include="Volo.Abp.Swashbuckle" Version="7.4.0-rc.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

24
shared/EShopOnAbp.Shared.Hosting.AspNetCore/SwaggerConfigurationHelper.cs

@ -38,4 +38,28 @@ public static class SwaggerConfigurationHelper
options.CustomSchemaIds(type => type.FullName); options.CustomSchemaIds(type => type.FullName);
}); });
} }
public static void ConfigureWithOidc(
ServiceConfigurationContext context,
string authority,
string[] scopes,
string apiTitle,
string apiVersion = "v1",
string apiName = "v1",
string[]? flows = null,
string? discoveryEndpoint = null
)
{
context.Services.AddAbpSwaggerGenWithOidc(
authority: authority,
scopes: scopes,
flows: flows,
discoveryEndpoint: discoveryEndpoint,
options =>
{
options.SwaggerDoc(apiName, new OpenApiInfo { Title = apiTitle, Version = apiVersion });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
}
} }

2
shared/EShopOnAbp.Shared.Hosting.Gateways/EShopOnAbp.Shared.Hosting.Gateways.csproj

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="1.0.0" /> <PackageReference Include="Yarp.ReverseProxy" Version="2.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

31
shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs

@ -1,5 +1,4 @@
using System.Linq; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -18,32 +17,12 @@ public static class YarpSwaggerUIBuilderExtensions
{ {
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>(); var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var logger = context.ServiceProvider.GetRequiredService<ILogger<ApplicationInitializationContext>>(); var logger = context.ServiceProvider.GetRequiredService<ILogger<ApplicationInitializationContext>>();
var proxyConfigProvider = context.ServiceProvider.GetRequiredService<IProxyConfigProvider>(); var proxyConfig = context.ServiceProvider.GetRequiredService<IProxyConfigProvider>().GetConfig();
var yarpConfig = proxyConfigProvider.GetConfig();
var routedClusters = yarpConfig.Clusters foreach (var cluster in proxyConfig.Clusters)
.SelectMany(t => t.Destinations,
(clusterId, destination) => new {clusterId.ClusterId, destination.Value});
var groupedClusters = routedClusters
.GroupBy(q => q.Value.Address)
.Select(t => t.First())
.Distinct()
.ToList();
foreach (var clusterGroup in groupedClusters)
{ {
var routeConfig = yarpConfig.Routes.FirstOrDefault(q => options.SwaggerEndpoint($"/swagger-json/{cluster.ClusterId}/swagger/v1/swagger.json",
q.ClusterId == clusterGroup.ClusterId); $"{cluster.ClusterId} API");
if (routeConfig == null)
{
logger.LogWarning($"Swagger UI: Couldn't find route configuration for {clusterGroup.ClusterId}...");
continue;
}
options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
} }
}); });

Loading…
Cancel
Save