fix(dashboard): enforce auth lifetimes on live hub connections and circuits (DSH-006)
Hub tokens and cookies bounded only the handshake: an open hub socket kept its connect-time roles and tag grants indefinitely, and a Blazor circuit never revisited its sign-in. The hub-token ticket now carries the token expiry and the hubs are mapped with CloseOnAuthenticationExpiration. Circuits use DashboardRevalidatingAuthenticationStateProvider, which signs a circuit out past the cookie's 8-hour idle lifetime or when a role it holds is no longer granted by GroupToRole. LDAP membership changes and sign-out in another tab are still only picked up at the age limit or on reconnect (documented).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Server.Circuits;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
@@ -114,6 +115,10 @@ public static class DashboardServiceCollectionExtensions
|
||||
services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents(circuit =>
|
||||
circuit.DisconnectedCircuitRetentionPeriod = DisconnectedCircuitRetention);
|
||||
// Registered after AddInteractiveServerComponents so it replaces the default
|
||||
// ServerAuthenticationStateProvider: a circuit's sign-in is otherwise captured once at
|
||||
// circuit start and never revisited (DSH-006).
|
||||
services.AddScoped<AuthenticationStateProvider, DashboardRevalidatingAuthenticationStateProvider>();
|
||||
services.AddSignalR();
|
||||
|
||||
// DEV/TEST ONLY. Read directly from configuration here because authentication scheme
|
||||
@@ -154,7 +159,7 @@ public static class DashboardServiceCollectionExtensions
|
||||
// ExpireTimeSpan) via the shared ZbCookieDefaults.Apply. requireHttps is set to
|
||||
// its default (true / Always) here and overridden per-environment by the
|
||||
// PostConfigure below; the 8-hour idle timeout is preserved (not the 30-min default).
|
||||
ZbCookieDefaults.Apply(cookieOptions, requireHttps: true, idleTimeout: TimeSpan.FromHours(8));
|
||||
ZbCookieDefaults.Apply(cookieOptions, requireHttps: true, idleTimeout: DashboardAuthenticationDefaults.CookieIdleTimeout);
|
||||
// Cookie name, path, and redirect paths are MxGateway-specific — set after Apply
|
||||
// so they are never overwritten by the shared helper (Apply intentionally skips name).
|
||||
// This is the canonical default; it is overridden per-environment from
|
||||
|
||||
Reference in New Issue
Block a user