| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Permissions; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Identity.Permissions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stable resource names for Identity. 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 IdentityPermissions |
| | | 12 | | { |
| | | 13 | | /// <summary>Manage user accounts.</summary> |
| | | 14 | | public const string Users = "identity/users"; |
| | | 15 | | /// <summary>Manage roles and the permissions they carry.</summary> |
| | | 16 | | public const string Roles = "identity/roles"; |
| | | 17 | | /// <summary>Create API client applications.</summary> |
| | | 18 | | public const string Applications = "identity/applications"; |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary>Contributes the Identity resources to the permission catalog.</summary> |
| | | 22 | | [UsedImplicitly] |
| | | 23 | | public sealed class IdentityPermissionsDescriptorProvider : IPermissionDescriptorProvider |
| | | 24 | | { |
| | | 25 | | /// <inheritdoc /> |
| | | 26 | | public IEnumerable<PermissionDescriptor> GetDescriptors() => |
| | 6 | 27 | | [ |
| | 6 | 28 | | new(IdentityPermissions.Users, [CoreVerbs.View, CoreVerbs.Create, CoreVerbs.Update, CoreVerbs.Delete], "Users", |
| | 6 | 29 | | new(IdentityPermissions.Roles, [CoreVerbs.View, CoreVerbs.Create, CoreVerbs.Update, CoreVerbs.Delete], "Roles", |
| | 6 | 30 | | new(IdentityPermissions.Applications, [CoreVerbs.Create], "Applications", "Create API client applications.", "Id |
| | 6 | 31 | | ]; |
| | | 32 | | } |