1. Changes in DI container
a. Specified RequireHttpsPermanent and SSL port MVC pipeline options b. Configured HttpsRedirection 2. Used HttpsRedirection MiddleWare
This commit is contained in:
parent
a62648bac9
commit
0d63172dc8
@ -1,24 +1,7 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using IdentityServer4.Services;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.ServiceFabric;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Certificates;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Certificates;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Data;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
|
||||
using Microsoft.eShopOnContainers.Services.Identity.API.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
{
|
||||
@ -52,7 +35,16 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
|
||||
services.Configure<AppSettings>(Configuration);
|
||||
|
||||
services.AddMvc();
|
||||
services.AddMvc(opts =>
|
||||
{
|
||||
opts.SslPort = 4105;
|
||||
opts.RequireHttpsPermanent = true;
|
||||
});
|
||||
|
||||
services.AddHttpsRedirection(opts =>
|
||||
{
|
||||
opts.HttpsPort = 4105;
|
||||
});
|
||||
|
||||
if (Configuration.GetValue<string>("IsClusterEnv") == bool.TrueString)
|
||||
{
|
||||
@ -129,6 +121,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var pathBase = Configuration["PATH_BASE"];
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
|
@ -41,6 +41,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
opts.CheckConsentNeeded = context => true;
|
||||
opts.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
services.AddHttpsRedirection(opts=>
|
||||
{
|
||||
opts.HttpsPort = 4100;
|
||||
});
|
||||
services.AddAppInsight(Configuration)
|
||||
.AddHealthChecks(Configuration)
|
||||
.AddCustomMvc(Configuration)
|
||||
@ -73,7 +77,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
app.UsePathBase(pathBase);
|
||||
}
|
||||
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseCookiePolicy();
|
||||
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
@ -156,7 +160,11 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
services.AddOptions();
|
||||
services.Configure<AppSettings>(configuration);
|
||||
|
||||
services.AddMvc();
|
||||
services.AddMvc(opts=>
|
||||
{
|
||||
opts.SslPort = 4100;
|
||||
opts.RequireHttpsPermanent = true;
|
||||
});
|
||||
|
||||
services.AddSession();
|
||||
|
||||
|
@ -1,18 +1,4 @@
|
||||
using eShopOnContainers.WebSPA;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.ServiceFabric;
|
||||
using Microsoft.AspNetCore.Antiforgery;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.IO;
|
||||
using WebSPA.Infrastructure;
|
||||
|
||||
namespace eShopConContainers.WebSPA
|
||||
@ -26,7 +12,7 @@ namespace eShopConContainers.WebSPA
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
private IHostingEnvironment _hostingEnv;
|
||||
private readonly IHostingEnvironment _hostingEnv;
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
_hostingEnv = env;
|
||||
@ -70,11 +56,21 @@ namespace eShopConContainers.WebSPA
|
||||
|
||||
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
|
||||
|
||||
services.AddMvc()
|
||||
services
|
||||
.AddMvc(opts =>
|
||||
{
|
||||
opts.SslPort = 4104;
|
||||
opts.RequireHttpsPermanent = true;
|
||||
})
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
|
||||
services.AddHttpsRedirection(opts =>
|
||||
{
|
||||
opts.HttpsPort = 4104;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -90,6 +86,8 @@ namespace eShopConContainers.WebSPA
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
// Configure XSRF middleware, This pattern is for SPA style applications where XSRF token is added on Index page
|
||||
// load and passed back token on every subsequent async request
|
||||
// app.Use(async (context, next) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user