| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Permissions; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Api.Permissions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stable resource names for Workflows. Endpoints reference these constants rather than string |
| | | 9 | | /// literals, and the descriptors below are declared alongside them so the two cannot drift. |
| | | 10 | | /// </summary> |
| | | 11 | | public static class WorkflowPermissions |
| | | 12 | | { |
| | | 13 | | /// <summary>Author, publish, run, and refresh workflow definitions.</summary> |
| | | 14 | | public const string Definitions = "workflows/definitions"; |
| | | 15 | | /// <summary>Inspect, delete, and revert individual definition versions.</summary> |
| | | 16 | | public const string DefinitionVersions = "workflows/definitions/versions"; |
| | | 17 | | /// <summary>Inspect, import, delete, and cancel workflow instances.</summary> |
| | | 18 | | public const string Instances = "workflows/instances"; |
| | | 19 | | /// <summary>Inspect activity execution records and summaries.</summary> |
| | | 20 | | public const string ActivityExecutions = "workflows/activity-executions"; |
| | | 21 | | /// <summary>Inspect runtime status, and pause, resume, or drain the runtime.</summary> |
| | | 22 | | public const string Runtime = "workflows/runtime"; |
| | | 23 | | /// <summary>Inspect, replay, and delete bookmark queue dead-letter items.</summary> |
| | | 24 | | public const string BookmarkQueueDeadLetters = "workflows/bookmark-queue/dead-letters"; |
| | | 25 | | /// <summary>Trigger workflow events.</summary> |
| | | 26 | | public const string Events = "workflows/events"; |
| | | 27 | | /// <summary>Complete external workflow tasks.</summary> |
| | | 28 | | public const string Tasks = "workflows/tasks"; |
| | | 29 | | /// <summary>Execute activity tests.</summary> |
| | | 30 | | public const string Tests = "workflows/tests"; |
| | | 31 | | /// <summary>Browse available activity types and their options.</summary> |
| | | 32 | | public const string DescriptorsActivities = "workflows/descriptors/activities"; |
| | | 33 | | /// <summary>Browse available expression types.</summary> |
| | | 34 | | public const string DescriptorsExpressions = "workflows/descriptors/expressions"; |
| | | 35 | | /// <summary>Browse available storage drivers.</summary> |
| | | 36 | | public const string DescriptorsStorageDrivers = "workflows/descriptors/storage-drivers"; |
| | | 37 | | /// <summary>Browse available variable types.</summary> |
| | | 38 | | public const string DescriptorsVariables = "workflows/descriptors/variables"; |
| | | 39 | | /// <summary>Browse available commit strategies.</summary> |
| | | 40 | | public const string DescriptorsCommitStrategies = "workflows/descriptors/commit-strategies"; |
| | | 41 | | /// <summary>Browse available incident strategies.</summary> |
| | | 42 | | public const string DescriptorsIncidentStrategies = "workflows/descriptors/incident-strategies"; |
| | | 43 | | /// <summary>Browse available log persistence strategies.</summary> |
| | | 44 | | public const string DescriptorsLogPersistenceStrategies = "workflows/descriptors/log-persistence-strategies"; |
| | | 45 | | /// <summary>Browse available output converters.</summary> |
| | | 46 | | public const string DescriptorsOutputConverters = "workflows/descriptors/output-converters"; |
| | | 47 | | /// <summary>Browse available workflow activation strategies.</summary> |
| | | 48 | | public const string DescriptorsActivationStrategies = "workflows/descriptors/activation-strategies"; |
| | | 49 | | /// <summary>Inspect which features are installed in this deployment.</summary> |
| | | 50 | | public const string SystemFeatures = "system/features"; |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | /// <summary>Contributes the Workflows resources to the permission catalog.</summary> |
| | | 54 | | [UsedImplicitly] |
| | | 55 | | public sealed class WorkflowPermissionsDescriptorProvider : IPermissionDescriptorProvider |
| | | 56 | | { |
| | | 57 | | /// <inheritdoc /> |
| | | 58 | | public IEnumerable<PermissionDescriptor> GetDescriptors() => |
| | 3 | 59 | | [ |
| | 3 | 60 | | new(WorkflowPermissions.Definitions, [CoreVerbs.View, CoreVerbs.Write, CoreVerbs.Delete, CoreVerbs.Execute, "pub |
| | 3 | 61 | | new(WorkflowPermissions.DefinitionVersions, [CoreVerbs.View, CoreVerbs.Delete, "revert"], "Workflow definition v |
| | 3 | 62 | | new(WorkflowPermissions.Instances, [CoreVerbs.View, CoreVerbs.Write, CoreVerbs.Delete, "cancel"], "Workflow inst |
| | 3 | 63 | | new(WorkflowPermissions.ActivityExecutions, [CoreVerbs.View], "Activity executions", "Inspect activity execution |
| | 3 | 64 | | new(WorkflowPermissions.Runtime, [CoreVerbs.View, "control"], "Workflow runtime", "Inspect runtime status, and p |
| | 3 | 65 | | new(WorkflowPermissions.BookmarkQueueDeadLetters, [CoreVerbs.View, CoreVerbs.Delete, "replay"], "Bookmark queue |
| | 3 | 66 | | new(WorkflowPermissions.Events, ["trigger"], "Workflow events", "Trigger workflow events.", "Workflows"), |
| | 3 | 67 | | new(WorkflowPermissions.Tasks, ["complete"], "Workflow tasks", "Complete external workflow tasks.", "Workflows") |
| | 3 | 68 | | new(WorkflowPermissions.Tests, [CoreVerbs.Execute], "Activity tests", "Execute activity tests.", "Workflows"), |
| | 3 | 69 | | new(WorkflowPermissions.DescriptorsActivities, [CoreVerbs.View], "Activity descriptors", "Browse available activ |
| | 3 | 70 | | new(WorkflowPermissions.DescriptorsExpressions, [CoreVerbs.View], "Expression descriptors", "Browse available ex |
| | 3 | 71 | | new(WorkflowPermissions.DescriptorsStorageDrivers, [CoreVerbs.View], "Storage driver descriptors", "Browse avail |
| | 3 | 72 | | new(WorkflowPermissions.DescriptorsVariables, [CoreVerbs.View], "Variable descriptors", "Browse available variab |
| | 3 | 73 | | new(WorkflowPermissions.DescriptorsCommitStrategies, [CoreVerbs.View], "Commit strategy descriptors", "Browse av |
| | 3 | 74 | | new(WorkflowPermissions.DescriptorsIncidentStrategies, [CoreVerbs.View], "Incident strategy descriptors", "Brows |
| | 3 | 75 | | new(WorkflowPermissions.DescriptorsLogPersistenceStrategies, [CoreVerbs.View], "Log persistence strategy descrip |
| | 3 | 76 | | new(WorkflowPermissions.DescriptorsOutputConverters, [CoreVerbs.View], "Output converter descriptors", "Browse a |
| | 3 | 77 | | new(WorkflowPermissions.DescriptorsActivationStrategies, [CoreVerbs.View], "Activation strategy descriptors", "B |
| | 3 | 78 | | new(WorkflowPermissions.SystemFeatures, [CoreVerbs.View], "Installed features", "Inspect which features are inst |
| | 3 | 79 | | ]; |
| | | 80 | | } |