| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Authorization; |
| | | 3 | | using Elsa.Identity.Permissions; |
| | | 4 | | using Elsa.Permissions; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Identity.Endpoints.Permissions.List; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Returns the permission catalog. A role editor renders from this rather than hard-coding permission |
| | | 11 | | /// strings, which is what keeps clients from drifting out of step with the server. |
| | | 12 | | /// </summary> |
| | | 13 | | [PublicAPI] |
| | 3 | 14 | | internal class List(IPermissionDescriptorRegistry registry) : ElsaEndpointWithoutRequest<Response> |
| | | 15 | | { |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | public override void Configure() |
| | | 18 | | { |
| | 3 | 19 | | Get("/identity/permissions"); |
| | | 20 | | |
| | | 21 | | // If you may see roles, you may see what roles can contain. |
| | 3 | 22 | | RequirePermission(IdentityPermissions.Roles, CoreVerbs.View); |
| | 3 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | | 26 | | public override Task<Response> ExecuteAsync(CancellationToken cancellationToken) |
| | | 27 | | { |
| | 0 | 28 | | var resources = registry.List() |
| | 0 | 29 | | .Select(x => new ResourceDescriptor(x.Resource, x.SupportedVerbs, x.NonCoreVerbs, x.DisplayName, x.Descripti |
| | 0 | 30 | | .ToArray(); |
| | | 31 | | |
| | 0 | 32 | | return Task.FromResult(new Response(Authorization.CoreVerbs.All, resources)); |
| | | 33 | | } |
| | | 34 | | } |