| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Permissions; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Labels.Permissions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stable resource names for Labels. 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 LabelPermissions |
| | | 12 | | { |
| | | 13 | | /// <summary>Manage labels.</summary> |
| | | 14 | | public const string Labels = "labels"; |
| | | 15 | | |
| | | 16 | | /// <summary>View and change the labels applied to a workflow definition.</summary> |
| | | 17 | | public const string WorkflowDefinitionLabels = "workflows/definitions/labels"; |
| | | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary>Contributes the Labels resources to the permission catalog.</summary> |
| | | 21 | | [UsedImplicitly] |
| | | 22 | | public sealed class LabelPermissionsDescriptorProvider : IPermissionDescriptorProvider |
| | | 23 | | { |
| | | 24 | | /// <inheritdoc /> |
| | | 25 | | public IEnumerable<PermissionDescriptor> GetDescriptors() => |
| | 0 | 26 | | [ |
| | 0 | 27 | | new(LabelPermissions.Labels, [CoreVerbs.View, CoreVerbs.Create, CoreVerbs.Update, CoreVerbs.Delete], "Labels", " |
| | 0 | 28 | | new(LabelPermissions.WorkflowDefinitionLabels, [CoreVerbs.View, CoreVerbs.Update], "Workflow definition labels", |
| | 0 | 29 | | ]; |
| | | 30 | | } |