| | | 1 | | namespace Elsa.Permissions; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Module-contributed metadata for one resource: what it is called, what it means, and which verbs it |
| | | 5 | | /// supports. The catalog built from these descriptors is what lets a role editor render without |
| | | 6 | | /// hard-coding permission strings, and what the coverage gate validates endpoint declarations against. |
| | | 7 | | /// </summary> |
| | | 8 | | /// <param name="Resource">The hierarchical resource path, for example <c>workflows/definitions</c>.</param> |
| | | 9 | | /// <param name="SupportedVerbs"> |
| | | 10 | | /// The verbs this resource accepts. A resource declares either <c>create</c> + <c>update</c>, or |
| | | 11 | | /// <c>write</c> — never both. The wildcard is deliberately absent: it is not a verb a user selects. |
| | | 12 | | /// </param> |
| | | 13 | | /// <param name="DisplayName">A human-readable name for a role editor.</param> |
| | | 14 | | /// <param name="Description">What granting this resource allows.</param> |
| | | 15 | | /// <param name="Category">A grouping for presentation, such as <c>Workflows</c>.</param> |
| | | 16 | | /// <param name="Verified"> |
| | | 17 | | /// <c>false</c> for an implicit descriptor auto-registered because a module declared a permission that |
| | | 18 | | /// resolved to no declared descriptor. The module keeps working and the gap stays visible in the catalog. |
| | | 19 | | /// </param> |
| | 100 | 20 | | public sealed record PermissionDescriptor( |
| | 334 | 21 | | string Resource, |
| | 11 | 22 | | IReadOnlyCollection<string> SupportedVerbs, |
| | 0 | 23 | | string DisplayName, |
| | 0 | 24 | | string Description, |
| | 0 | 25 | | string Category, |
| | 100 | 26 | | bool Verified = true) |
| | | 27 | | { |
| | | 28 | | /// <summary>The verbs this resource supports that fall outside the recommended core set.</summary> |
| | 1 | 29 | | public IReadOnlyCollection<string> NonCoreVerbs { get; } = |
| | 273 | 30 | | SupportedVerbs.Where(x => !Authorization.CoreVerbs.IsCore(x)).ToArray(); |
| | | 31 | | |
| | | 32 | | /// <summary>Whether this resource supports <paramref name="verb"/>.</summary> |
| | 8 | 33 | | public bool Supports(string verb) => SupportedVerbs.Contains(verb, StringComparer.Ordinal); |
| | | 34 | | } |