Class SignedCapabilityGrantEndpointValidator
- Namespace
- AsiBackbone.AspNetCore.CapabilityGrants
- Assembly
- AsiBackbone.AspNetCore.dll
Opt-in IEndpointCapabilityGrantValidator that accepts only a signed, request-bound capability grant carried as a CapabilityGrantToken.
public sealed class SignedCapabilityGrantEndpointValidator : IEndpointCapabilityGrantValidator
- Inheritance
-
SignedCapabilityGrantEndpointValidator
- Implements
- Inherited Members
Remarks
For every decision that is not already denied, the validator reads the token from the request, decodes it, resolves the request binding, and validates the grant with CreateBoundExecutionBoundary(CapabilityGrantBindingExpectations, string?, string?, IEnumerable<string>?, DateTimeOffset?, string?, string?, string?, string?, string?, string?, bool, bool, int, TimeSpan, string?, string?, string?, string?, string?, string?, CanonicalPayloadOptions?) built from the authenticated actor, the endpoint operation and scopes, the policy version and hash of the current decision, and the configured issuer and audience. Proof verification is always required. A use is consumed for every outcome except acknowledgment-required: that request is answered with a challenge and never executes, so its grant is verified but left for the acknowledged retry, which is validated and consumed in turn.
Every result other than Valid produces a denied decision with a reason code from SignedCapabilityGrantReasonCodes, whatever VerificationPolicyAction the core validator attached. A not-yet-valid grant, an unavailable use store, an unspecified use state, or a grant missing a required acknowledgment reference is therefore denied rather than deferred, escalated, or challenged. A valid grant returns the current decision unchanged, so it never bypasses an acknowledgment challenge, and records the grant in IEndpointCapabilityGrantFeature for the decision receipt. An existing denial is returned unchanged before the token is read, so it consumes no use.
The host supplies the IGovernanceSignatureVerificationService, the ICapabilityGrantUseStore, and an ICapabilityGrantRequestBindingProvider. A missing service denies the request rather than weakening validation.
Constructors
SignedCapabilityGrantEndpointValidator(IServiceProvider, IHttpGovernanceActorContextResolver, IOptions<SignedCapabilityGrantOptions>, ILogger<SignedCapabilityGrantEndpointValidator>?)
Initializes a new instance of the SignedCapabilityGrantEndpointValidator class.
public SignedCapabilityGrantEndpointValidator(IServiceProvider serviceProvider, IHttpGovernanceActorContextResolver actorContextResolver, IOptions<SignedCapabilityGrantOptions> options, ILogger<SignedCapabilityGrantEndpointValidator>? logger = null)
Parameters
serviceProviderIServiceProviderThe request service provider used to resolve host-supplied services.
actorContextResolverIHttpGovernanceActorContextResolverThe actor resolver that supplies the authenticated subject.
optionsIOptions<SignedCapabilityGrantOptions>The signed capability grant options.
loggerILogger<SignedCapabilityGrantEndpointValidator>An optional logger for denial diagnostics; token content is never logged.
Exceptions
- ArgumentNullException
A required argument is null.
- InvalidOperationException
The options are invalid.
Methods
ValidateAsync(HttpContext, EndpointGovernanceDescriptor, GovernanceDecision, CancellationToken)
Validates endpoint capability requirements before endpoint execution continues.
public ValueTask<GovernanceDecision> ValidateAsync(HttpContext httpContext, EndpointGovernanceDescriptor descriptor, GovernanceDecision currentDecision, CancellationToken cancellationToken = default)
Parameters
httpContextHttpContextThe current HTTP context.
descriptorEndpointGovernanceDescriptorThe endpoint governance descriptor.
currentDecisionGovernanceDecisionThe current governance decision.
cancellationTokenCancellationTokenA token that can cancel validation.
Returns
- ValueTask<GovernanceDecision>
A governance decision representing the capability validation result.
Remarks
The validator is called for every decision that is not already denied, so currentDecision
may allow the request, carry a warning, require acknowledgment, be deferred, or recommend escalation. A validator
that does not find every required grant should return a denied decision instead of preserving any of those
outcomes. A valid grant may preserve the current decision so the host can continue its acknowledgment, deferral,
or escalation flow.