Skip to content

Commit

Permalink
Fix Security Bug: No permissions applied to version endpoints (#5008)
Browse files Browse the repository at this point in the history
List,Delete, and Revert endpoints for editing endpoints by version were set to allow anonymous, meaning no authorisation policies were applied.

I have changed these to apply permissions as per the rest of the API.
  • Loading branch information
IsaacHayes1995 authored and sfmskywalker committed Feb 28, 2024
1 parent f695b36 commit 875afd4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.Workflows.Management.Contracts;
using Elsa.Abstractions;
using Elsa.Workflows.Management.Contracts;
using FastEndpoints;
using JetBrains.Annotations;

Expand All @@ -8,7 +9,7 @@ namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Version;
/// Deletes a specific version of a workflow definition.
/// </summary>
[PublicAPI]
public class DeleteVersion : EndpointWithoutRequest
public class DeleteVersion : ElsaEndpointWithoutRequest
{
private readonly IWorkflowDefinitionManager _workflowDefinitionManager;

Expand All @@ -22,7 +23,7 @@ public DeleteVersion(IWorkflowDefinitionManager workflowDefinitionManager)
public override void Configure()
{
Delete("workflow-definitions/{definitionId}/version/{version}");
AllowAnonymous();
ConfigurePermissions("delete:workflow-definitions");
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.Common.Entities;
using Elsa.Abstractions;
using Elsa.Common.Entities;
using Elsa.Common.Models;
using Elsa.Workflows.Management.Contracts;
using Elsa.Workflows.Management.Filters;
Expand All @@ -9,7 +10,7 @@
namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Version;

[PublicAPI]
internal class ListVersions : EndpointWithoutRequest
internal class ListVersions : ElsaEndpointWithoutRequest
{
private readonly IWorkflowDefinitionStore _store;

Expand All @@ -21,7 +22,7 @@ public ListVersions(IWorkflowDefinitionStore store)
public override void Configure()
{
Get("workflow-definitions/{definitionId}/versions");
AllowAnonymous();
ConfigurePermissions("read:workflow-definitions");
}

public override async Task HandleAsync(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Elsa.Workflows.Management.Contracts;
using Elsa.Abstractions;
using Elsa.Workflows.Management.Contracts;
using FastEndpoints;
using JetBrains.Annotations;

namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Version;

[PublicAPI]
internal class RevertVersion : EndpointWithoutRequest
internal class RevertVersion : ElsaEndpointWithoutRequest
{
private readonly IWorkflowDefinitionManager _workflowDefinitionManager;

Expand All @@ -17,7 +18,7 @@ public RevertVersion(IWorkflowDefinitionManager workflowDefinitionManager)
public override void Configure()
{
Post("workflow-definitions/{definitionId}/revert/{version}");
AllowAnonymous();
ConfigurePermissions("publish:workflow-definitions");
}

public override async Task HandleAsync(CancellationToken ct)
Expand Down

0 comments on commit 875afd4

Please sign in to comment.