elsa-core/src/modules/Elsa.Dashboard.Api
Sipke Schoorstra f969cd61e8
refactor(auth)!: retire the legacy permission constants and duplicate descriptor types (#7987)
* refactor(auth)!: retire the legacy permission constants and duplicate descriptors

Completes the cutover started in #7980. Seven `<Module>Permissions` classes
holding `verb:resource` strings are removed: AIPermissions, ConsoleLogs,
Dashboard, ExternalAuthentication, OpenTelemetry, Secrets and StructuredLogs.
AIPermissions was not in #7982's list, which was written before the cutover
finished; it is dead by the same measure as the rest.

Removed rather than marked obsolete, which #7982 asked to be an explicit
decision. Every string these classes held carries two colons, so it does not
parse under the new grammar and authorizes nothing. Keeping them obsolete
would leave code that compiles, still reads as a permission check, and
silently grants no access -- a warning that is easy to suppress in front of a
runtime failure that is invisible. A compile error names the call site and
can be fixed against the migration guide's mapping table. Classes their own
modules still reference, WorkflowPermissions and IdentityPermissions among
them, are untouched.

External Authentication's parallel descriptor system is collapsed onto the
core types: its own PermissionDescriptor record, its IPermissionDescriptorProvider
and IPermissionDescriptorRegistry, and DefaultPermissionDescriptorRegistry.

That was not only tidiness. The module's registry was fed exclusively by its
legacy names, so after the cutover every well-formed grant failed the
`unknown_permission_descriptor` check and the warning fired constantly for
correct configuration. The resolver now consults the core catalog, which is
keyed by resource and lists the verbs each accepts, and a wildcard is treated
as advertised because it names a pattern rather than a resource to look up.
The descriptor endpoint serves the core catalog too: choosing what an
external mapping may confer means choosing from everything Elsa declares.

The module contributes its resource descriptors explicitly rather than
relying on the host's assembly scan, for the same reason it registers
AddElsaAuthorization itself.

The two naming tests now pin the new resource name instead of the legacy
string. The convention worth holding was always that the module is called
'diagnostics/console-logs', not that a retired constant kept its old value.

Refs #7982

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(client): match the permission descriptor client model to the catalog

Moving the descriptor endpoint onto the core catalog changed its shape from a
single permission string to a resource plus the verbs that resource accepts,
and the Refit client model kept the old one. It still deserialized and still
compiled, handing callers a blank Name and no way to reach the verbs -- the
data went missing without anything failing.

The client model now mirrors the served descriptor, and a contract test
compares the two property sets so the next divergence is a test failure
rather than an empty field. NonCoreVerbs is excluded: the server derives it
from SupportedVerbs, so a client holding the verbs can compute it.

Found by review, not by the suites: nothing here throws.

Refs #7982

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 06:04:32 +02:00
..
Endpoints/Dashboard feat(auth)!: structured authorization model, phases 1-6 (#7980) 2026-08-24 23:44:55 +02:00
Extensions
Features
Permissions refactor(auth)!: retire the legacy permission constants and duplicate descriptor types (#7987) 2026-08-25 06:04:32 +02:00
Services
ShellFeatures Remove PackageManifestCategories and update feature categories to inline strings 2026-06-08 09:48:55 +02:00
AssemblyInfo.cs
Elsa.Dashboard.Api.csproj
README.md

Elsa Dashboard API

Elsa.Dashboard.Api exposes aggregate endpoints used by Elsa Studio's operational dashboard. Hosts opt in by enabling the dashboard API feature/module; older hosts that do not install this module simply do not expose the /dashboard/* routes.

Endpoints

GET /dashboard/overview

Query parameters:

  • range: Optional dashboard range key. Supported values are 1h, 24h, and 7d. Unknown or missing values resolve to 24h.
  • includeSystem: Optional boolean. Defaults to false; when false, workflow instance aggregates exclude system workflows.

Returns:

  • Backend and environment names.
  • Runtime status, including whether the runtime is accepting work, active execution cycle count, ingress source count, and failed ingress source count.
  • Contributor-composed workflow instance metrics for running, completed, faulted, suspended, interrupted, incident-bearing, and average completed duration.
  • Contributor-composed structured log and console log diagnostic summaries.
  • Applied range and resolved from/to timestamps.

POST /dashboard/workflow-trends

Body:

  • range: Optional range key.
  • granularity: Optional bucket granularity. Defaults to minute for 1h, hour for 24h, and day for 7d.
  • includeSystem: Optional boolean.

Returns ordered buckets with created/started, finished, faulted, suspended, and incident-bearing counts.

GET /dashboard/needs-attention

Query parameters:

  • range: Optional range key.
  • take: Optional maximum number of findings. Clamped to 1..50.
  • includeSystem: Optional boolean.

Returns priority-ordered findings derived from runtime state, workflow metrics, and available diagnostics summaries. Consumers should preserve backend ordering.

GET /dashboard/recent-activity

Query parameters:

  • range: Optional range key.
  • take: Optional maximum number of workflow instance summaries. Clamped to 1..100.
  • includeSystem: Optional boolean.

Returns compact workflow instance activity ordered by latest update. The response intentionally omits workflow variables, inputs, outputs, and execution state.

POST /dashboard/workflow-hotspots

Body:

  • range: Optional range key.
  • metric: One of Faults, Executions, Incidents, or Duration.
  • take: Optional maximum number of rows. Clamped to 1..50.
  • includeSystem: Optional boolean.

Returns top workflow definitions for the selected metric. Studio treats this panel as optional and may omit it if the endpoint is unavailable.

Capability States

Diagnostics summaries carry a capability object:

  • Available: The diagnostic provider is installed and returned data.
  • NotInstalled: The diagnostic provider is absent from the host.
  • Unauthorized: The provider rejected access.
  • Unavailable: The provider is installed but failed to produce a summary.

Dashboard overview degrades each diagnostics capability independently so a structured log failure does not prevent workflow metrics, runtime status, or console diagnostics from rendering.

Extension Model

Dashboard core owns the public /dashboard/* routes, permissions, range resolution, and contributor orchestration. Feature modules own their own dashboard data. This keeps the dependency direction open for extension:

  • Elsa.Dashboard.Api references Elsa.Dashboard.Abstractions.
  • Feature modules reference Elsa.Dashboard.Abstractions and register one or more IDashboardContributor implementations.
  • Dashboard core does not reference workflow, diagnostics, or future feature modules.

IDashboardContributor is intentionally broad enough for a module to contribute only the surfaces it owns:

  • GetOverviewAsync for metric cards, panel summaries, runtime status, workflow metrics, and diagnostic summary slices.
  • GetFindingsAsync for priority-ordered findings.
  • GetWorkflowTrendsAsync for trend buckets.
  • GetRecentActivityAsync for compact activity rows.
  • GetWorkflowHotspotsAsync for hotspot rows.

Contributor failures are isolated by the dashboard composer. A failed contributor does not break the whole dashboard response; request cancellation is still honored.

Backend Weather Example

using Elsa.Dashboard.Abstractions.Contracts;
using Elsa.Dashboard.Abstractions.Extensions;
using Elsa.Dashboard.Abstractions.Models;

public class WeatherDashboardContributor(IWeatherService weatherService) : IDashboardContributor
{
    public string Id => "weather";
    public int Order => 500;

    public async ValueTask<DashboardOverviewContribution?> GetOverviewAsync(DashboardContext context)
    {
        var forecast = await weatherService.GetForecastAsync(context.CancellationToken);

        return new()
        {
            Panels =
            [
                new()
                {
                    Id = "weather.current",
                    Title = "Weather",
                    Summary = forecast.Summary,
                    Order = 10,
                    Navigation = new() { Kind = "Weather", Target = "current" }
                }
            ]
        };
    }
}

services.AddDashboardContributor<WeatherDashboardContributor>();

The example belongs in a hypothetical Elsa.Weather.Dashboard module or inside an existing Weather module, not in Elsa.Dashboard.Api.

Studio Widget Model

Studio follows the same dependency direction. Elsa.Studio.Dashboard owns the dashboard route, refresh/range state, zone rendering, shared DashboardWidgetContext, and registration helpers. Feature modules register widgets into zones such as metrics, findings, primary panels, secondary panels, and diagnostics/status.

Minimal Studio Weather widget registration:

services.AddDashboardWidget<WeatherDashboardWidget>(
    "weather.current",
    DashboardWidgetZones.SecondaryPanels,
    order: 500,
    title: "Weather",
    payloadKind: "Weather");

WeatherDashboardWidget can read the shared dashboard snapshot and navigation services from DashboardWidgetContext. The widget should live in Elsa.Studio.Weather.Dashboard or the Studio Weather module, not in Elsa.Studio.Dashboard.

Diagnostics Migration

Structured-log and console-log dashboard behavior is diagnostics-owned:

  • Backend summaries and findings are contributed by the corresponding diagnostics modules.
  • Studio widgets are registered by the corresponding diagnostics Studio modules.
  • Installing Dashboard alone does not install diagnostics. Installing diagnostics plus Dashboard causes diagnostics summaries and widgets to appear.

Studio Integration Notes

  • Studio should detect dashboard API support with a guarded dashboard call or feature metadata and show an explicit unavailable state when the endpoints are missing.
  • Studio should keep the last successful dashboard snapshot visible after a refresh failure.
  • Metric and finding targets should route to existing workflow instance, structured log, and console pages. Destination pages that do not yet support URL filters should still be linked and can add deep-link filters later.
  • The API is read-only. Dashboard consumers must not add workflow write actions to the first dashboard slice.