Bugfix due to https not being honored

This commit is contained in:
Rhywden
2026-08-23 19:13:01 +02:00
parent 3f785b157a
commit dc6afd090f
+14
View File
@@ -4,6 +4,7 @@ using Marten;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.HttpOverrides;
using MudBlazor.Services;
using System.Net.Http.Headers;
using System.Security.Claims;
@@ -14,6 +15,18 @@ using Wollmilchsau.Services.Ldap;
var builder = WebApplication.CreateBuilder(args);
if (!builder.Environment.IsDevelopment())
{
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
// The application is reachable only through the secured reverse-proxy network.
options.ForwardedHeaders = ForwardedHeaders.XForwardedProto;
options.ForwardLimit = 1;
options.KnownIPNetworks.Clear();
options.KnownProxies.Clear();
});
}
var oidcConfiguration = builder.Configuration.GetRequiredSection("OIDC");
var oidcScopes = oidcConfiguration.GetSection("Scopes").Get<string[]>()
?? throw new ConfigurationException("OIDC:Scopes");
@@ -125,6 +138,7 @@ var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseForwardedHeaders();
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();