1. Configured CookiePolicyOptions to the DI Container (Line 39) and used CookiePolicy MiddleWare (line 76) in order to support GDPR Cookie compliance
2. Set compatibility version to 2.1 according to documentation (line 172) 3. HTTPS Support a. Updated MVC pipeline to support HTTPS and specified port (Line 166-171) b. Configure HTTPS redirection options to the DI (line 51) and used HttpsRedirection MiddleWare (Line 75) c. 4. Used var instead of type (Line 100, 123, 145, 250-252)
This commit is contained in:
parent
12b1be780e
commit
e901aafc5c
@ -36,12 +36,22 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
// This method gets called by the runtime. Use this method to add services to the IoC container.
|
// This method gets called by the runtime. Use this method to add services to the IoC container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddAppInsight(Configuration)
|
services.Configure<CookiePolicyOptions>(opts =>
|
||||||
|
{
|
||||||
|
opts.MinimumSameSitePolicy = SameSiteMode.None;
|
||||||
|
opts.CheckConsentNeeded = context => true;
|
||||||
|
});
|
||||||
|
services
|
||||||
|
.AddAppInsight(Configuration)
|
||||||
.AddHealthChecks(Configuration)
|
.AddHealthChecks(Configuration)
|
||||||
.AddCustomMvc(Configuration)
|
.AddCustomMvc(Configuration)
|
||||||
.AddHttpClientServices(Configuration)
|
.AddHttpClientServices(Configuration)
|
||||||
//.AddHttpClientLogging(Configuration) //Opt-in HttpClientLogging config
|
//.AddHttpClientLogging(Configuration) //Opt-in HttpClientLogging config
|
||||||
.AddCustomAuthentication(Configuration);
|
.AddCustomAuthentication(Configuration);
|
||||||
|
services.AddHttpsRedirection(options =>
|
||||||
|
{
|
||||||
|
options.HttpsPort = 4100;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
@ -59,9 +69,13 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Error");
|
app.UseExceptionHandler("/Error");
|
||||||
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
var pathBase = Configuration["PATH_BASE"];
|
app.UseHttpsRedirection();
|
||||||
|
app.UseCookiePolicy();
|
||||||
|
|
||||||
|
string pathBase = Configuration["PATH_BASE"];
|
||||||
if (!string.IsNullOrEmpty(pathBase))
|
if (!string.IsNullOrEmpty(pathBase))
|
||||||
{
|
{
|
||||||
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
|
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
|
||||||
@ -83,7 +97,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
|
||||||
var log = loggerFactory.CreateLogger("identity");
|
ILogger log = loggerFactory.CreateLogger("identity");
|
||||||
|
|
||||||
WebContextSeed.Seed(app, env, loggerFactory);
|
WebContextSeed.Seed(app, env, loggerFactory);
|
||||||
|
|
||||||
@ -106,7 +120,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");
|
string orchestratorType = configuration.GetValue<string>("OrchestratorType");
|
||||||
|
|
||||||
if (orchestratorType?.ToUpper() == "K8S")
|
if (orchestratorType?.ToUpper() == "K8S")
|
||||||
{
|
{
|
||||||
@ -128,8 +142,8 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
{
|
{
|
||||||
services.AddHealthChecks(checks =>
|
services.AddHealthChecks(checks =>
|
||||||
{
|
{
|
||||||
var minutes = 1;
|
int minutes = 1;
|
||||||
if (int.TryParse(configuration["HealthCheck:Timeout"], out var minutesParsed))
|
if (int.TryParse(configuration["HealthCheck:Timeout"], out int minutesParsed))
|
||||||
{
|
{
|
||||||
minutes = minutesParsed;
|
minutes = minutesParsed;
|
||||||
}
|
}
|
||||||
@ -149,7 +163,13 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
services.AddOptions();
|
services.AddOptions();
|
||||||
services.Configure<AppSettings>(configuration);
|
services.Configure<AppSettings>(configuration);
|
||||||
|
|
||||||
services.AddMvc();
|
services
|
||||||
|
.AddMvc(opts =>
|
||||||
|
{
|
||||||
|
opts.SslPort = 4100;
|
||||||
|
opts.RequireHttpsPermanent = true;
|
||||||
|
})
|
||||||
|
.SetCompatibilityVersion(AspNetCore.Mvc.CompatibilityVersion.Version_2_1);
|
||||||
|
|
||||||
services.AddSession();
|
services.AddSession();
|
||||||
|
|
||||||
@ -227,9 +247,9 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
|
|
||||||
public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var useLoadTest = configuration.GetValue<bool>("UseLoadTest");
|
bool useLoadTest = configuration.GetValue<bool>("UseLoadTest");
|
||||||
var identityUrl = configuration.GetValue<string>("IdentityUrl");
|
string identityUrl = configuration.GetValue<string>("IdentityUrl");
|
||||||
var callBackUrl = configuration.GetValue<string>("CallBackUrl");
|
string callBackUrl = configuration.GetValue<string>("CallBackUrl");
|
||||||
|
|
||||||
// Add Authentication services
|
// Add Authentication services
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user