diff options
author | crupest <crupest@outlook.com> | 2019-02-07 00:39:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-02-07 00:39:51 +0800 |
commit | 4262a25addf26705e4c5ab07acafd3eb8702fa4b (patch) | |
tree | d39469b839a1ef31bcb0b3afdeb0ae351bf63bd0 /Timeline/Startup.cs | |
parent | 167deab9648f2f2fc7f69b9eeee03f0d18be3c50 (diff) | |
download | timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.tar.gz timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.tar.bz2 timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.zip |
Add authorization.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r-- | Timeline/Startup.cs | 16 |
1 files changed, 7 insertions, 9 deletions
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<IUserService, UserService>(); + services.AddSingleton<IJwtService, JwtService>(); } // 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 => |