1. Configured CookiePolicyOptions in the DI container

2. Used CookiePolicy MiddlwWare
This commit is contained in:
rafsanulhasan 2018-09-01 15:02:50 +06:00
parent 8110a95111
commit 6b96741de6

View File

@ -36,6 +36,11 @@ namespace Microsoft.eShopOnContainers.WebMVC
// This method gets called by the runtime. Use this method to add services to the IoC container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(opts =>
{
opts.CheckConsentNeeded = context => true;
opts.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAppInsight(Configuration)
.AddHealthChecks(Configuration)
.AddCustomMvc(Configuration)
@ -69,6 +74,8 @@ namespace Microsoft.eShopOnContainers.WebMVC
}
app.UseCookiePolicy();
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
app.Map("/liveness", lapp => lapp.Run(async ctx => ctx.Response.StatusCode = 200));
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
@ -83,7 +90,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
app.UseAuthentication();
var log = loggerFactory.CreateLogger("identity");
ILogger log = loggerFactory.CreateLogger("identity");
WebContextSeed.Seed(app, env, loggerFactory);
@ -106,7 +113,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
{
services.AddApplicationInsightsTelemetry(configuration);
var orchestratorType = configuration.GetValue<string>("OrchestratorType");
string orchestratorType = configuration.GetValue<string>("OrchestratorType");
if (orchestratorType?.ToUpper() == "K8S")
{
@ -128,8 +135,8 @@ namespace Microsoft.eShopOnContainers.WebMVC
{
services.AddHealthChecks(checks =>
{
var minutes = 1;
if (int.TryParse(configuration["HealthCheck:Timeout"], out var minutesParsed))
int minutes = 1;
if (int.TryParse(configuration["HealthCheck:Timeout"], out int minutesParsed))
{
minutes = minutesParsed;
}
@ -227,9 +234,9 @@ namespace Microsoft.eShopOnContainers.WebMVC
public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
{
var useLoadTest = configuration.GetValue<bool>("UseLoadTest");
var identityUrl = configuration.GetValue<string>("IdentityUrl");
var callBackUrl = configuration.GetValue<string>("CallBackUrl");
bool useLoadTest = configuration.GetValue<bool>("UseLoadTest");
string identityUrl = configuration.GetValue<string>("IdentityUrl");
string callBackUrl = configuration.GetValue<string>("CallBackUrl");
// Add Authentication services