fix(dashboard): validate __Host- cookie vs RequireHttpsCookie; surface login flags (mxaccessgw#196)

O19: reject a __Host- CookieName with RequireHttpsCookie=false at startup.
O20: project DisableLogin, AutoLoginUser, RequireHttpsCookie and CookieName into
EffectiveDashboardConfiguration and show them on the Settings page.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 12:28:21 -05:00
parent 417b9e5a19
commit f3a452810e
6 changed files with 72 additions and 2 deletions
@@ -386,6 +386,17 @@ public sealed class GatewayOptionsValidator : OptionsValidatorBase<GatewayOption
"MxGateway:Dashboard:DisableLogin must not be true in the Production environment; it disables all dashboard authentication.");
}
// A __Host- cookie must carry Secure; with RequireHttpsCookie=false the cookie is only
// Secure on HTTPS requests, so over plain HTTP browsers silently drop it and login
// appears to succeed yet never sticks. Reject the combination at startup (R21-O19).
if (!options.RequireHttpsCookie
&& options.CookieName is { } cookieName
&& cookieName.StartsWith("__Host-", StringComparison.OrdinalIgnoreCase))
{
builder.Add(
"MxGateway:Dashboard:CookieName must not use the '__Host-' prefix when MxGateway:Dashboard:RequireHttpsCookie is false; browsers silently drop a __Host- cookie that is not Secure.");
}
// GroupToRole shape is validated even when the dashboard is disabled so
// misconfiguration surfaces at startup; emptiness is allowed, with the
// consequence that no LDAP user can sign in (login returns "no roles