fix(dashboard): enforce page [Authorize] on in-circuit navigation via AuthorizeRouteView (DSH-001, #243)
Routes.razor used RouteView, which ignores [Authorize]. With the interactive router, an in-circuit navigation never meets endpoint authorization, so anonymous localhost could open /alarms and a Viewer could open /admin/secrets (secret metadata list). Both were confirmed reachable by the new route test before the change; AuthorizeRouteView now renders a Not Authorized panel instead.
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
@* AuthorizeRouteView, not RouteView (DSH-001): the router is interactive, so a navigation that
|
||||
starts inside a circuit never issues an HTTP request and never meets endpoint authorization.
|
||||
Only AuthorizeRouteView evaluates a page's [Authorize] attribute on that path — the Alarms page
|
||||
(AlarmsPolicy) and the shared Secrets page (secrets:manage) both rely on it. Pages without an
|
||||
attribute are rendered as before; the endpoint ViewerPolicy still gates the initial request. *@
|
||||
<Router AppAssembly="@typeof(Routes).Assembly"
|
||||
AdditionalAssemblies="new[]{ typeof(ZB.MOM.WW.Secrets.Ui.SecretsPage).Assembly }">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
|
||||
<NotAuthorized>
|
||||
<PageTitle>Dashboard - Not Authorized</PageTitle>
|
||||
<section class="dashboard-section">
|
||||
<h1 class="h4 mb-3">Not Authorized</h1>
|
||||
@if (context.User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<p class="mb-0">Your dashboard role does not grant access to this page.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="mb-0">This page requires a signed-in dashboard role. <a href="/login">Sign in</a></p>
|
||||
}
|
||||
</section>
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
|
||||
Reference in New Issue
Block a user