From 101631a0041f22570d7c2d9378cbfd0cec5ca14b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 7 Feb 2019 00:39:51 +0800 Subject: Add authorization. --- Timeline/Startup.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Timeline/Startup.cs') diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index 6dde227f..2a0f437f 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -9,6 +9,7 @@ using Microsoft.IdentityModel.Tokens; using System.Text; using Timeline.Configs; using Timeline.Services; +using Microsoft.AspNetCore.HttpOverrides; namespace Timeline { @@ -49,6 +50,7 @@ namespace Timeline }); services.AddSingleton(); + services.AddSingleton(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -61,20 +63,16 @@ namespace Timeline else { app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); } - - // When not in test environment, use https redirection. - // Because I found some problems using https redirection in test mode. - if (!env.IsTest()) - app.UseHttpsRedirection(); - - app.UseStaticFiles(); app.UseSpaStaticFiles(); + app.UseForwardedHeaders(new ForwardedHeadersOptions + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }); + app.UseAuthentication(); app.UseMvc(routes => -- cgit v1.2.3