| | | 1 | | namespace AsiBackbone.AspNetCore.Endpoints; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Request feature that records the capability grant an <see cref="IEndpointCapabilityGrantValidator" /> accepted for |
| | | 5 | | /// the current endpoint governance evaluation. |
| | | 6 | | /// </summary> |
| | | 7 | | /// <remarks> |
| | | 8 | | /// <see cref="DefaultEndpointGovernanceService" /> clears this feature before it calls the validator and, when audit is |
| | | 9 | | /// requested, copies <see cref="GrantId" /> into the decision receipt's |
| | | 10 | | /// <see cref="Core.Audit.IDecisionReceipt.CapabilityGrantId" />. <see cref="Core.Audit.AuditLedgerRecord.FromDecisionRe |
| | | 11 | | /// then records it as <see cref="Core.Audit.AuditLedgerRecord.CapabilityTokenId" />. A validator should set the feature |
| | | 12 | | /// after the grant was accepted, and never when it returns a denial. |
| | | 13 | | /// </remarks> |
| | | 14 | | public interface IEndpointCapabilityGrantFeature |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets the identifier of the accepted capability grant. |
| | | 18 | | /// </summary> |
| | | 19 | | string GrantId { get; } |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Default <see cref="IEndpointCapabilityGrantFeature" /> implementation. |
| | | 24 | | /// </summary> |
| | | 25 | | public sealed class EndpointCapabilityGrantFeature : IEndpointCapabilityGrantFeature |
| | | 26 | | { |
| | | 27 | | /// <summary> |
| | | 28 | | /// Initializes a new instance of the <see cref="EndpointCapabilityGrantFeature" /> class. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="grantId">The identifier of the accepted capability grant.</param> |
| | | 31 | | /// <exception cref="ArgumentException"><paramref name="grantId" /> is null, empty, or whitespace.</exception> |
| | 16 | 32 | | public EndpointCapabilityGrantFeature(string grantId) |
| | | 33 | | { |
| | 16 | 34 | | ArgumentException.ThrowIfNullOrWhiteSpace(grantId); |
| | 16 | 35 | | GrantId = grantId.Trim(); |
| | 16 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <inheritdoc /> |
| | | 39 | | public string GrantId { get; } |
| | | 40 | | } |