|
3 | 3 | using Microsoft.AspNetCore.Authentication.Cookies; |
4 | 4 | using Microsoft.AspNetCore.Builder; |
5 | 5 | using Microsoft.AspNetCore.Hosting; |
| 6 | +using Microsoft.AspNetCore.HttpOverrides; |
| 7 | +using Microsoft.Extensions.Configuration; |
6 | 8 | using Microsoft.Extensions.DependencyInjection; |
7 | 9 | using Microsoft.Extensions.Logging; |
8 | 10 | using Newtonsoft.Json; |
9 | 11 | using SimpleIdServer.Jwt; |
10 | 12 | using SimpleIdServer.Jwt.Extensions; |
11 | 13 | using System.Collections.Generic; |
12 | 14 | using System.IO; |
| 15 | +using System.Linq; |
13 | 16 | using System.Security.Cryptography; |
14 | 17 |
|
15 | 18 | namespace SimpleIdServer.OpenID.Startup |
16 | 19 | { |
17 | 20 | public class Startup |
18 | 21 | { |
19 | | - public Startup(IHostingEnvironment env) { } |
| 22 | + private readonly IHostingEnvironment _env; |
| 23 | + private readonly IConfiguration _configuration; |
| 24 | + |
| 25 | + public Startup(IHostingEnvironment env, IConfiguration configuration) |
| 26 | + { |
| 27 | + _env = env; |
| 28 | + _configuration = configuration; |
| 29 | + } |
20 | 30 |
|
21 | 31 | public void ConfigureServices(IServiceCollection services) |
22 | 32 | { |
@@ -46,10 +56,20 @@ public void ConfigureServices(IServiceCollection services) |
46 | 56 | .AddScopes(DefaultConfiguration.Scopes) |
47 | 57 | .AddJsonWebKeys(new List<JsonWebKey> { sigJsonWebKey }) |
48 | 58 | .AddLoginPasswordAuthentication(); |
| 59 | + services.Configure<ForwardedHeadersOptions>(options => |
| 60 | + { |
| 61 | + options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; |
| 62 | + }); |
49 | 63 | } |
50 | 64 |
|
51 | 65 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) |
52 | 66 | { |
| 67 | + if (_configuration.GetChildren().Any(i => i.Key == "pathBase")) |
| 68 | + { |
| 69 | + app.UsePathBase(_configuration["pathBase"]); |
| 70 | + } |
| 71 | + |
| 72 | + app.UseForwardedHeaders(); |
53 | 73 | app.UseCors("AllowAll"); |
54 | 74 | app.UseAuthentication(); |
55 | 75 | app.UseStaticFiles(); |
|
0 commit comments