|
@ -7,13 +7,12 @@ |
|
|
using global::Ordering.API.Application.IntegrationEvents.Events; |
|
|
using global::Ordering.API.Application.IntegrationEvents.Events; |
|
|
using global::Ordering.API.Infrastructure.Filters; |
|
|
using global::Ordering.API.Infrastructure.Filters; |
|
|
using global::Ordering.API.Infrastructure.Middlewares; |
|
|
using global::Ordering.API.Infrastructure.Middlewares; |
|
|
|
|
|
using HealthChecks.UI.Client; |
|
|
using Infrastructure.AutofacModules; |
|
|
using Infrastructure.AutofacModules; |
|
|
using Infrastructure.Filters; |
|
|
using Infrastructure.Filters; |
|
|
using Infrastructure.Services; |
|
|
using Infrastructure.Services; |
|
|
using Microsoft.ApplicationInsights.Extensibility; |
|
|
|
|
|
using Microsoft.ApplicationInsights.ServiceFabric; |
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|
|
|
|
|
using Microsoft.AspNetCore.Builder; |
|
|
using Microsoft.AspNetCore.Builder; |
|
|
|
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.Azure.ServiceBus; |
|
|
using Microsoft.Azure.ServiceBus; |
|
@ -26,18 +25,15 @@ |
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services; |
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Ordering.Infrastructure; |
|
|
using Ordering.Infrastructure; |
|
|
using RabbitMQ.Client; |
|
|
using RabbitMQ.Client; |
|
|
using Swashbuckle.AspNetCore.Swagger; |
|
|
|
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Data.Common; |
|
|
using System.Data.Common; |
|
|
using System.IdentityModel.Tokens.Jwt; |
|
|
using System.IdentityModel.Tokens.Jwt; |
|
|
using System.Reflection; |
|
|
using System.Reflection; |
|
|
using HealthChecks.UI.Client; |
|
|
|
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
|
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks; |
|
|
|
|
|
|
|
|
|
|
|
public class Startup |
|
|
public class Startup |
|
|
{ |
|
|
{ |
|
@ -148,12 +144,6 @@ |
|
|
// Enable K8s telemetry initializer
|
|
|
// Enable K8s telemetry initializer
|
|
|
services.AddApplicationInsightsKubernetesEnricher(); |
|
|
services.AddApplicationInsightsKubernetesEnricher(); |
|
|
} |
|
|
} |
|
|
if (orchestratorType?.ToUpper() == "SF") |
|
|
|
|
|
{ |
|
|
|
|
|
// Enable SF telemetry initializer
|
|
|
|
|
|
services.AddSingleton<ITelemetryInitializer>((serviceProvider) => |
|
|
|
|
|
new FabricTelemetryInitializer()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return services; |
|
|
return services; |
|
|
} |
|
|
} |
|
@ -249,23 +239,26 @@ |
|
|
services.AddSwaggerGen(options => |
|
|
services.AddSwaggerGen(options => |
|
|
{ |
|
|
{ |
|
|
options.DescribeAllEnumsAsStrings(); |
|
|
options.DescribeAllEnumsAsStrings(); |
|
|
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info |
|
|
|
|
|
|
|
|
options.SwaggerDoc("v1", new OpenApi.Models.OpenApiInfo |
|
|
{ |
|
|
{ |
|
|
Title = "Ordering HTTP API", |
|
|
Title = "Ordering HTTP API", |
|
|
Version = "v1", |
|
|
Version = "v1", |
|
|
Description = "The Ordering Service HTTP API", |
|
|
|
|
|
TermsOfService = "Terms Of Service" |
|
|
|
|
|
|
|
|
Description = "The Ordering Service HTTP API" |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
options.AddSecurityDefinition("oauth2", new OAuth2Scheme |
|
|
|
|
|
|
|
|
options.AddSecurityDefinition("oauth2", new OpenApi.Models.OpenApiSecurityScheme |
|
|
{ |
|
|
{ |
|
|
Type = "oauth2", |
|
|
|
|
|
Flow = "implicit", |
|
|
|
|
|
AuthorizationUrl = $"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/authorize", |
|
|
|
|
|
TokenUrl = $"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token", |
|
|
|
|
|
Scopes = new Dictionary<string, string>() |
|
|
|
|
|
|
|
|
Flows = new OpenApi.Models.OpenApiOAuthFlows() |
|
|
{ |
|
|
{ |
|
|
{ "orders", "Ordering API" } |
|
|
|
|
|
|
|
|
Implicit = new OpenApi.Models.OpenApiOAuthFlow() |
|
|
|
|
|
{ |
|
|
|
|
|
AuthorizationUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/authorize"), |
|
|
|
|
|
TokenUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token"), |
|
|
|
|
|
Scopes = new Dictionary<string, string>() |
|
|
|
|
|
{ |
|
|
|
|
|
{ "orders", "Ordering API" } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -407,8 +400,8 @@ |
|
|
|
|
|
|
|
|
services.AddAuthentication(options => |
|
|
services.AddAuthentication(options => |
|
|
{ |
|
|
{ |
|
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |
|
|
|
|
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; |
|
|
|
|
|
|
|
|
options.DefaultAuthenticateScheme = AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme; |
|
|
|
|
|
options.DefaultChallengeScheme = AspNetCore.Authentication.JwtBearer.JwtBearerDefaults.AuthenticationScheme; |
|
|
|
|
|
|
|
|
}).AddJwtBearer(options => |
|
|
}).AddJwtBearer(options => |
|
|
{ |
|
|
{ |
|
|