Let EndpointSecurity express and record an "any of" permission requirement
Problem
EndpointPermissionRegistry (src/common/Elsa.Api.Common/Authorization/EndpointPermissionRegistry.cs) maps an endpoint type to exactly one Permission, and EndpointSecurity.RequirePermission records that permission. An endpoint that accepts either of two permissions can't be declared, so it can't be recorded either.
That case exists since #8562. The four single-purpose dashboard endpoints (workflow-trends, recent-activity, needs-attention, workflow-hotspots) accept dashboard:view or workflows/instances:view.
- They declare
RequireAuthenticatedOnly()plus a FastEndpoints pre-processor,RequireInstancesAccess<T>inElsa.Dashboard.Api/Authorization. - That pre-processor is the only one in elsa-core, and its remarks explain why.
- Anything that reads the registry sees these endpoints as needing no grant. That includes the endpoint-permission tests in Identity, UserTasks, Workflows.Api, ConsoleLogs and OpenTelemetry, and any tooling built on it.
Similar in-handler "any of" checks exist where part of a response depends on the permission: the dashboard overview's per-section filtering, and GET /descriptors/activities?refresh=true (#8556). Those are partial-response rules rather than endpoint gates, so they may stay in the handler.
Proposal
- Add
RequireAnyPermission(params (string Resource, string Verb)[] permissions)toEndpointSecurity. It should use the same evaluator and the sameEndpointSecurityOptions.SecurityIsEnabledsemantics asRequirePermission. - Let the registry record a permission set with "any of" semantics. Keep the current single-permission API working for existing callers. For example, keep
Find/Allreturning the single permission where there is exactly one, and add a members-aware accessor. Alternatively, make the change explicitly breaking and document it indoc/migrations/authorization-model.md. - Move the four dashboard endpoints to
RequireAnyPermission(dashboard:view, workflows/instances:view)and deleteRequireInstancesAccess<T>. - Update the registry consumers and their tests.
Acceptance criteria
- The four dashboard endpoints declare their requirement with
RequireAnyPermission, and the registry reports both permissions for them. - Behaviour is unchanged: 401 for anonymous callers, 403 without either permission, 200 with either one, and everything allowed when security is disabled. The existing
DashboardAuthorizationTestsstill pass. - Existing single-permission endpoints and registry consumers keep working. Any public API change is documented.
Source: elsa-workflows/elsa-core