fix(web): disable HTTPS redirection when not configured
The application forced HTTPS redirection and secure cookies even in HTTP-only mode (Docker deployment), preventing plain HTTP connections. Make UseHttpsRedirection() conditional on ASPNETCORE_URLS and change CookieSecurePolicy from Always to SameAsRequest.
This commit is contained in:
1 parent
fc5108a4fa
commit
261f922ad1
1 file changed
+10
-2
@@ -227,7 +227,9 @@ public partial class Program {
|
||||
options.Cookie.Name = ".Heimdall.Auth";
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.SameSite = SameSiteMode.Lax;
|
||||
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
|
||||
// Use SameAsRequest to support both HTTP and HTTPS deployments
|
||||
// In production with HTTPS, the cookie will still be secure
|
||||
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
|
||||
options.ExpireTimeSpan = TimeSpan.FromDays(7);
|
||||
options.SlidingExpiration = true;
|
||||
})
|
||||
@@ -322,7 +324,13 @@ public partial class Program {
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
// Only enable HTTPS redirection if HTTPS is actually configured
|
||||
var urls = Environment.GetEnvironmentVariable("ASPNETCORE_URLS") ?? "";
|
||||
if (urls.Contains("https://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
app.UseHttpsRedirection();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
Reference in new issue
Block a user