update startups
This commit is contained in:
parent
fe93901f08
commit
49cc39d731
@ -89,15 +89,18 @@ namespace OcelotApiGw
|
|||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHealthChecks("/hc", new HealthCheckOptions()
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
Predicate = _ => true,
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
|
||||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
{
|
||||||
});
|
Predicate = _ => true,
|
||||||
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
app.UseHealthChecks("/liveness", new HealthCheckOptions
|
});
|
||||||
{
|
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
|
||||||
Predicate = r => r.Name.Contains("self")
|
{
|
||||||
|
Predicate = r => r.Name.Contains("self")
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
|
@ -62,17 +62,6 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
|||||||
app.UsePathBase(pathBase);
|
app.UsePathBase(pathBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHealthChecks("/hc", new HealthCheckOptions()
|
|
||||||
{
|
|
||||||
Predicate = _ => true,
|
|
||||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseHealthChecks("/liveness", new HealthCheckOptions
|
|
||||||
{
|
|
||||||
Predicate = r => r.Name.Contains("self")
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
@ -87,7 +76,20 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator
|
|||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseMvc();
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
|
||||||
|
{
|
||||||
|
Predicate = _ => true,
|
||||||
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
|
});
|
||||||
|
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
|
||||||
|
{
|
||||||
|
Predicate = r => r.Name.Contains("self")
|
||||||
|
});
|
||||||
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
});
|
||||||
|
|
||||||
app.UseSwagger().UseSwaggerUI(c =>
|
app.UseSwagger().UseSwaggerUI(c =>
|
||||||
{
|
{
|
||||||
|
@ -61,17 +61,6 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
|||||||
app.UsePathBase(pathBase);
|
app.UsePathBase(pathBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHealthChecks("/hc", new HealthCheckOptions()
|
|
||||||
{
|
|
||||||
Predicate = _ => true,
|
|
||||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseHealthChecks("/liveness", new HealthCheckOptions
|
|
||||||
{
|
|
||||||
Predicate = r => r.Name.Contains("self")
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
@ -86,7 +75,20 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
|||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseMvc();
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
|
||||||
|
{
|
||||||
|
Predicate = _ => true,
|
||||||
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
|
});
|
||||||
|
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
|
||||||
|
{
|
||||||
|
Predicate = r => r.Name.Contains("self")
|
||||||
|
});
|
||||||
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
});
|
||||||
|
|
||||||
app.UseSwagger()
|
app.UseSwagger()
|
||||||
.UseSwaggerUI(c =>
|
.UseSwaggerUI(c =>
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using Microsoft.OpenApi.Models;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Webhooks.API.Infrastructure
|
namespace Webhooks.API.Infrastructure
|
||||||
{
|
{
|
||||||
public class AuthorizeCheckOperationFilter : IOperationFilter
|
public class AuthorizeCheckOperationFilter : IOperationFilter
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
// Check for authorize attribute
|
// Check for authorize attribute
|
||||||
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any() ||
|
var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType<AuthorizeAttribute>().Any() ||
|
||||||
@ -18,16 +16,21 @@ namespace Webhooks.API.Infrastructure
|
|||||||
|
|
||||||
if (!hasAuthorize) return;
|
if (!hasAuthorize) return;
|
||||||
|
|
||||||
operation.Responses.TryAdd("401", new Response { Description = "Unauthorized" });
|
operation.Responses.TryAdd("401", new OpenApiResponse { Description = "Unauthorized" });
|
||||||
operation.Responses.TryAdd("403", new Response { Description = "Forbidden" });
|
operation.Responses.TryAdd("403", new OpenApiResponse { Description = "Forbidden" });
|
||||||
|
|
||||||
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
|
var oAuthScheme = new OpenApiSecurityScheme
|
||||||
{
|
{
|
||||||
new Dictionary<string, IEnumerable<string>>
|
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "oauth2" }
|
||||||
{
|
|
||||||
{ "oauth2", new [] { "webhooksapi" } }
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
operation.Security = new List<OpenApiSecurityRequirement>
|
||||||
|
{
|
||||||
|
new OpenApiSecurityRequirement
|
||||||
|
{
|
||||||
|
[ oAuthScheme ] = new [] { "webhooksapi" }
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,10 @@
|
|||||||
using System;
|
using Autofac;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.Common;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Autofac;
|
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using Devspaces.Support;
|
using Devspaces.Support;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.ApplicationInsights.Extensibility;
|
|
||||||
using Microsoft.ApplicationInsights.ServiceFabric;
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Azure.ServiceBus;
|
using Microsoft.Azure.ServiceBus;
|
||||||
@ -31,7 +20,12 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Common;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using Webhooks.API.Infrastructure;
|
using Webhooks.API.Infrastructure;
|
||||||
using Webhooks.API.IntegrationEvents;
|
using Webhooks.API.IntegrationEvents;
|
||||||
using Webhooks.API.Services;
|
using Webhooks.API.Services;
|
||||||
@ -84,22 +78,25 @@ namespace Webhooks.API
|
|||||||
app.UsePathBase(pathBase);
|
app.UsePathBase(pathBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHealthChecks("/hc", new HealthCheckOptions()
|
|
||||||
{
|
|
||||||
Predicate = _ => true,
|
|
||||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseHealthChecks("/liveness", new HealthCheckOptions
|
|
||||||
{
|
|
||||||
Predicate = r => r.Name.Contains("self")
|
|
||||||
});
|
|
||||||
|
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
|
|
||||||
ConfigureAuth(app);
|
ConfigureAuth(app);
|
||||||
|
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions()
|
||||||
|
{
|
||||||
|
Predicate = _ => true,
|
||||||
|
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||||
|
});
|
||||||
|
endpoints.MapHealthChecks("/liveness", new HealthCheckOptions
|
||||||
|
{
|
||||||
|
Predicate = r => r.Name.Contains("self")
|
||||||
|
});
|
||||||
|
|
||||||
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
});
|
||||||
|
|
||||||
app.UseSwagger()
|
app.UseSwagger()
|
||||||
.UseSwaggerUI(c =>
|
.UseSwaggerUI(c =>
|
||||||
@ -138,19 +135,7 @@ namespace Webhooks.API
|
|||||||
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddApplicationInsightsTelemetry(configuration);
|
services.AddApplicationInsightsTelemetry(configuration);
|
||||||
var orchestratorType = configuration.GetValue<string>("OrchestratorType");
|
services.AddApplicationInsightsKubernetesEnricher();
|
||||||
|
|
||||||
if (orchestratorType?.ToUpper() == "K8S")
|
|
||||||
{
|
|
||||||
// Enable K8s telemetry initializer
|
|
||||||
services.AddApplicationInsightsKubernetesEnricher();
|
|
||||||
}
|
|
||||||
if (orchestratorType?.ToUpper() == "SF")
|
|
||||||
{
|
|
||||||
// Enable SF telemetry initializer
|
|
||||||
services.AddSingleton<ITelemetryInitializer>((serviceProvider) =>
|
|
||||||
new FabricTelemetryInitializer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
@ -161,7 +146,7 @@ namespace Webhooks.API
|
|||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||||
})
|
})
|
||||||
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
|
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
|
||||||
.AddControllersAsServices();
|
.AddControllersAsServices();
|
||||||
|
|
||||||
services.AddCors(options =>
|
services.AddCors(options =>
|
||||||
@ -203,23 +188,26 @@ namespace Webhooks.API
|
|||||||
services.AddSwaggerGen(options =>
|
services.AddSwaggerGen(options =>
|
||||||
{
|
{
|
||||||
options.DescribeAllEnumsAsStrings();
|
options.DescribeAllEnumsAsStrings();
|
||||||
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
|
options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
|
||||||
{
|
{
|
||||||
Title = "eShopOnContainers - Webhooks HTTP API",
|
Title = "eShopOnContainers - Webhooks HTTP API",
|
||||||
Version = "v1",
|
Version = "v1",
|
||||||
Description = "The Webhooks Microservice HTTP API. This is a simple webhooks CRUD registration entrypoint",
|
Description = "The Webhooks Microservice HTTP API. This is a simple webhooks CRUD registration entrypoint"
|
||||||
TermsOfService = "Terms Of Service"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
options.AddSecurityDefinition("oauth2", new OAuth2Scheme
|
options.AddSecurityDefinition("oauth2", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||||
{
|
{
|
||||||
Type = "oauth2",
|
Flows = new Microsoft.OpenApi.Models.OpenApiOAuthFlows()
|
||||||
Flow = "implicit",
|
|
||||||
AuthorizationUrl = $"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/authorize",
|
|
||||||
TokenUrl = $"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token",
|
|
||||||
Scopes = new Dictionary<string, string>()
|
|
||||||
{
|
{
|
||||||
{ "webhooks", "Webhooks API" }
|
Implicit = new Microsoft.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>()
|
||||||
|
{
|
||||||
|
{ "marketing", "Marketing API" }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,21 +4,24 @@
|
|||||||
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
|
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||||
|
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||||
|
<LangVersion>8.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(Microsoft_AspNetCore_Razor_Design)" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="$(Microsoft_VisualStudio_Azure_Containers_Tools_Targets)" />
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="$(Autofac_Extensions_DependencyInjection)" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="$(Autofac_Extensions_DependencyInjection)" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="$(Microsoft_ApplicationInsights_AspNetCore)" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="$(Microsoft_ApplicationInsights_AspNetCore)" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="$(Microsoft_ApplicationInsights_DependencyCollector)" />
|
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="$(Microsoft_ApplicationInsights_DependencyCollector)" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="$(Microsoft_ApplicationInsights_Kubernetes)" />
|
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="$(Microsoft_ApplicationInsights_Kubernetes)" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.ServiceFabric" Version="2.2.2" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="$(Microsoft_Extensions_Logging_AzureAppServices)" />
|
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="$(Microsoft_Extensions_Logging_AzureAppServices)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="$(Microsoft_AspNetCore_HealthChecks)" />
|
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="$(Microsoft_AspNetCore_HealthChecks)" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="$(AspNetCore_HealthChecks_UI_Client)" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="$(AspNetCore_HealthChecks_UI_Client)" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(Swashbuckle_AspNetCore)" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(Swashbuckle_AspNetCore)" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(Microsoft_AspNetCore_Authentication_JwtBearer)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj" />
|
||||||
|
@ -108,13 +108,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddApplicationInsightsTelemetry(configuration);
|
services.AddApplicationInsightsTelemetry(configuration);
|
||||||
var orchestratorType = configuration.GetValue<string>("OrchestratorType");
|
services.AddApplicationInsightsKubernetesEnricher();
|
||||||
|
|
||||||
if (orchestratorType?.ToUpper() == "K8S")
|
|
||||||
{
|
|
||||||
// Enable K8s telemetry initializer
|
|
||||||
services.AddApplicationInsightsKubernetesEnricher();
|
|
||||||
}
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
@ -232,52 +226,25 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
})
|
})
|
||||||
.AddCookie(setup => setup.ExpireTimeSpan = TimeSpan.FromMinutes(sessionCookieLifetime))
|
.AddCookie(setup => setup.ExpireTimeSpan = TimeSpan.FromMinutes(sessionCookieLifetime))
|
||||||
.AddJwtBearer(options =>
|
.AddOpenIdConnect(options =>
|
||||||
{
|
{
|
||||||
//options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||||
//options.Authority = identityUrl.ToString();
|
|
||||||
//options.SignedOutRedirectUri = callBackUrl.ToString();
|
|
||||||
//options.ClientId = useLoadTest ? "mvctest" : "mvc";
|
|
||||||
//options.ClientSecret = "secret";
|
|
||||||
//options.ResponseType = useLoadTest ? "code id_token token" : "code id_token";
|
|
||||||
//options.SaveTokens = true;
|
|
||||||
//options.GetClaimsFromUserInfoEndpoint = true;
|
|
||||||
//options.RequireHttpsMetadata = false;
|
|
||||||
//options.Scope.Add("openid");
|
|
||||||
//options.Scope.Add("profile");
|
|
||||||
//options.Scope.Add("orders");
|
|
||||||
//options.Scope.Add("basket");
|
|
||||||
//options.Scope.Add("marketing");
|
|
||||||
//options.Scope.Add("locations");
|
|
||||||
//options.Scope.Add("webshoppingagg");
|
|
||||||
//options.Scope.Add("orders.signalrhub");
|
|
||||||
|
|
||||||
//options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
|
||||||
options.Authority = identityUrl.ToString();
|
options.Authority = identityUrl.ToString();
|
||||||
options.ForwardSignOut = callBackUrl.ToString();
|
options.SignedOutRedirectUri = callBackUrl.ToString();
|
||||||
//options.ClientId = useLoadTest ? "mvctest" : "mvc";
|
options.ClientId = useLoadTest ? "mvctest" : "mvc";
|
||||||
//options.ClientSecret = "secret";
|
options.ClientSecret = "secret";
|
||||||
|
options.ResponseType = useLoadTest ? "code id_token token" : "code id_token";
|
||||||
if (useLoadTest)
|
options.SaveTokens = true;
|
||||||
{
|
options.GetClaimsFromUserInfoEndpoint = true;
|
||||||
options.Configuration.ResponseTypesSupported.Add("code id_token token");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.Configuration.ResponseTypesSupported.Add("code id_token");
|
|
||||||
}
|
|
||||||
|
|
||||||
options.SaveToken = true;
|
|
||||||
//options.GetClaimsFromUserInfoEndpoint = true;
|
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Configuration.ScopesSupported.Add("openid");
|
options.Scope.Add("openid");
|
||||||
options.Configuration.ScopesSupported.Add("profile");
|
options.Scope.Add("profile");
|
||||||
options.Configuration.ScopesSupported.Add("orders");
|
options.Scope.Add("orders");
|
||||||
options.Configuration.ScopesSupported.Add("basket");
|
options.Scope.Add("basket");
|
||||||
options.Configuration.ScopesSupported.Add("marketing");
|
options.Scope.Add("marketing");
|
||||||
options.Configuration.ScopesSupported.Add("locations");
|
options.Scope.Add("locations");
|
||||||
options.Configuration.ScopesSupported.Add("webshoppingagg");
|
options.Scope.Add("webshoppingagg");
|
||||||
options.Configuration.ScopesSupported.Add("orders.signalrhub");
|
options.Scope.Add("orders.signalrhub");
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
@ -36,7 +36,7 @@ namespace WebhookClient
|
|||||||
.AddCustomAuthentication(Configuration)
|
.AddCustomAuthentication(Configuration)
|
||||||
.AddTransient<IWebhooksClient, WebhooksClient>()
|
.AddTransient<IWebhooksClient, WebhooksClient>()
|
||||||
.AddSingleton<IHooksRepository, InMemoryHooksRepository>()
|
.AddSingleton<IHooksRepository, InMemoryHooksRepository>()
|
||||||
.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
@ -69,7 +69,7 @@ namespace WebhookClient
|
|||||||
var header = context.Request.Headers[HeaderNames.WebHookCheckHeader];
|
var header = context.Request.Headers[HeaderNames.WebHookCheckHeader];
|
||||||
var value = header.FirstOrDefault();
|
var value = header.FirstOrDefault();
|
||||||
var tokenToValidate = Configuration["Token"];
|
var tokenToValidate = Configuration["Token"];
|
||||||
if (!validateToken || value == tokenToValidate)
|
if (!validateToken || value == tokenToValidate)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(tokenToValidate))
|
if (!string.IsNullOrWhiteSpace(tokenToValidate))
|
||||||
{
|
{
|
||||||
@ -91,7 +91,11 @@ namespace WebhookClient
|
|||||||
});
|
});
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseRouting();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapDefaultControllerRoute();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<UserSecretsId>36215d41-f31a-4aa6-9929-bd67d650e7b5</UserSecretsId>
|
<UserSecretsId>36215d41-f31a-4aa6-9929-bd67d650e7b5</UserSecretsId>
|
||||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||||
|
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>8.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(Microsoft_AspNetCore_Razor_Design)" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="$(Microsoft_VisualStudio_Azure_Containers_Tools_Targets)" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="$(Microsoft_VisualStudio_Azure_Containers_Tools_Targets)" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="$(Microsoft_VisualStudio_Web_CodeGeneration_Design)" />
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="$(Microsoft_VisualStudio_Web_CodeGeneration_Design)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(Microsoft_AspNetCore_Authentication_OpenIdConnect)" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(Microsoft_AspNetCore_Authentication_OpenIdConnect)" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user