Class CapabilityTokenServiceExtensions
- Namespace
- ReferenceApplication.Web.Extensions
- Assembly
- ReferenceApplication.Web.dll
Provides the Reference Application's signed capability token composition.
public static class CapabilityTokenServiceExtensions
- Inheritance
-
CapabilityTokenServiceExtensions
- Inherited Members
Methods
AddApplicationCapabilityTokens(IServiceCollection, IConfiguration, IHostEnvironment)
Selects the capability grant model from Enabled and, when signed tokens are enabled, registers AsiBackbone's signed capability grant validator, public-key verifier, and EF Core use store, with the host-owned key material, issuance, and purge schedule.
public static IServiceCollection AddApplicationCapabilityTokens(this IServiceCollection services, IConfiguration configuration, IHostEnvironment environment)
Parameters
servicesIServiceCollectionThe service collection to configure.
configurationIConfigurationThe application configuration.
environmentIHostEnvironmentThe host environment, used to refuse the sample issuance signing key in Production by default.
Returns
- IServiceCollection
The same service collection so calls can be chained.
Remarks
Call after AddApplicationAsiBackbone, which registers the claim-backed
ClaimEndpointCapabilityGrantValidator, and after AddApplicationDataAccess, which registers
the ApplicationDbContext the use store writes to. While tokens are disabled the claim validator
stands. While they are enabled, it is removed and AddAsiBackboneSignedCapabilityGrants registers the
library validator in its place, because the library refuses to register beside another validator. The choice is
made here, from configuration, so exactly one validator is ever registered.
The method body is laid out in the order a host wires signed grants, and each step is marked with who owns it.
| Step | Owner, and what this sample registers |
|---|---|
| 1. Validator |
AsiBackbone, enabled by AddAsiBackboneSignedCapabilityGrants: token reading and decoding, proof
verification, subject, operation, scope, policy, time, and binding checks, use consumption, fail-closed denials
with documented reason codes, and the grant identifier on the decision receipt. Do not reimplement any of it.
|
| 2. Validator options | Host: issuer, audience, clock skew, and the pinned key identifier, mapped here from CapabilityTokenOptions. |
| 3. Request binding |
Host choice of an AsiBackbone provider: AddAsiBackboneFormFieldCapabilityGrantBinding. Keep it for form
posts; register another ICapabilityGrantRequestBindingProvider for JSON bodies or route-identified
resources.
|
| 4. Verification keys |
AsiBackbone, enabled by AddAsiBackboneKeySignatureVerification: the public-key
AsiBackbone.Core.Signing.IGovernanceSignatureVerificationService, with version selection for rotation and revocation. Host:
the trusted public keys, from VerificationKeys.
|
| 5. Use store |
AsiBackbone, enabled by AddAsiBackboneEfCoreCapabilityGrantUseStore: the
AsiBackbone.Core.CapabilityGrants.ICapabilityGrantUseStore whose consume is atomic across replicas sharing the database. Host: the
ApplicationDbContext, its migration, the retention grace period, and the purge schedule
(CapabilityGrantUsePurgeService).
|
| 6. Issuance | Host: entitlement, lifetime, the signing key, and where the issuer runs. CapabilityTokenIssuer composes the AsiBackbone signing helper and token encoding with CapabilityTokenSigningKey; production signs through a managed key service and may move issuance to a separate service. |
Options are validated at startup, so enabling tokens without a usable signing key, or without a trusted public key that matches it, stops the application before it serves a request.