More attempting to read forward headers
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Simon 2021-10-03 02:55:25 +01:00
parent afbcf4ae11
commit b7f07c36b9
1 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,12 @@ using Microsoft.Extensions.Configuration;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var Configuration = builder.Configuration; var Configuration = builder.Configuration;
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
// Add services to the container. // Add services to the container.
builder.Services.AddRazorPages(); builder.Services.AddRazorPages();
builder.Services.AddControllers(); builder.Services.AddControllers();
@ -24,7 +30,6 @@ builder.Services.AddAuthentication(options => {
options.ClientSecret = Configuration["oidc:clientsecret"]; options.ClientSecret = Configuration["oidc:clientsecret"];
options.Authority = @"https://auth.jacknet.io/auth/realms/JackNet"; options.Authority = @"https://auth.jacknet.io/auth/realms/JackNet";
//options.Authority = String.Format("https://{0}.onelogin.com/oidc/2", Configuration["oidc:region"]); //options.Authority = String.Format("https://{0}.onelogin.com/oidc/2", Configuration["oidc:region"]);
options.ResponseType = "code"; options.ResponseType = "code";
options.GetClaimsFromUserInfoEndpoint = true; options.GetClaimsFromUserInfoEndpoint = true;
} }
@ -36,10 +41,10 @@ var app = builder.Build();
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {
app.UseExceptionHandler("/Error"); app.UseExceptionHandler("/Error");
app.UseForwardedHeaders();
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts(); app.UseHsts();
app.UseForwardedHeaders();
} }
app.UseStaticFiles(); app.UseStaticFiles();