Browse Source

Updated gateways to use oidc for swagger

pull/186/head
Galip Tolga Erdem 3 years ago
parent
commit
a6fd7060f1
  1. 32
      gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs
  2. 32
      gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.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)

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();
});
} }
} }
Loading…
Cancel
Save