RollingHmacNonceService Class
Abblix.Oidc.Server
Abblix.Oidc.Server.Features.Nonces
RollingHmacNonceService Class
HMAC-SHA256 backed implementation of INonceService.
Issues stateless nonces of the form Base64Url(timestamp_8B || HMAC-SHA256(secret, timestamp_8B)[..16])
where secret is rotated on a configurable cadence and shared across
server instances via Microsoft.Extensions.Caching.Distributed.IDistributedCache, keyed by time bucket.
public class RollingHmacNonceService : Abblix.Oidc.Server.Features.Nonces.INonceService
Inheritance System.Object → RollingHmacNonceService
Implements INonceService
Remarks
The bucketed-secret design avoids any explicit lock or coordination on the
rotation boundary: every instance derives the same bucket index from the
nonce's embedded timestamp, looks up that bucket's secret in the
distributed cache, and either finds it or creates one with last-write-wins
semantics. Per RFC 9449 §11.3 a brief mismatch during the rotation race
surfaces to the DPoP client as a single retry with a fresh
DPoP-Nonce header, which is the protocol's intended recovery path;
other consumers of this service get the analogous one-retry behaviour
through their own challenge-response loop.
Constructors
RollingHmacNonceService(ILogger<RollingHmacNonceService>, IDistributedCache, IOptionsMonitor<OidcOptions>, TimeProvider) Constructor
HMAC-SHA256 backed implementation of INonceService.
Issues stateless nonces of the form Base64Url(timestamp_8B || HMAC-SHA256(secret, timestamp_8B)[..16])
where secret is rotated on a configurable cadence and shared across
server instances via Microsoft.Extensions.Caching.Distributed.IDistributedCache, keyed by time bucket.
public RollingHmacNonceService(Microsoft.Extensions.Logging.ILogger<Abblix.Oidc.Server.Features.Nonces.RollingHmacNonceService> logger, Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, Microsoft.Extensions.Options.IOptionsMonitor<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options, System.TimeProvider timeProvider);
Parameters
logger Microsoft.Extensions.Logging.ILogger<RollingHmacNonceService>
cache Microsoft.Extensions.Caching.Distributed.IDistributedCache
options Microsoft.Extensions.Options.IOptionsMonitor<OidcOptions>
timeProvider System.TimeProvider
Remarks
The bucketed-secret design avoids any explicit lock or coordination on the
rotation boundary: every instance derives the same bucket index from the
nonce's embedded timestamp, looks up that bucket's secret in the
distributed cache, and either finds it or creates one with last-write-wins
semantics. Per RFC 9449 §11.3 a brief mismatch during the rotation race
surfaces to the DPoP client as a single retry with a fresh
DPoP-Nonce header, which is the protocol's intended recovery path;
other consumers of this service get the analogous one-retry behaviour
through their own challenge-response loop.
Methods
RollingHmacNonceService.IssueAsync(CancellationToken) Method
Mints a fresh nonce string suitable for the DPoP-Nonce response
header. The returned value is opaque to callers — clients must echo it
verbatim.
public System.Threading.Tasks.Task<string> IssueAsync(System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
cancellationToken System.Threading.CancellationToken
Implements IssueAsync(CancellationToken)
Returns
System.Threading.Tasks.Task<System.String>
RollingHmacNonceService.ValidateAsync(string, CancellationToken) Method
Verifies that nonce was issued by this deployment and is still within the acceptance window.
public System.Threading.Tasks.Task<System.Nullable<Abblix.Oidc.Server.Features.Nonces.NonceValidationFailure>> ValidateAsync(string nonce, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters
nonce System.String
The nonce string echoed by the client in its DPoP
proof nonce claim.
cancellationToken System.Threading.CancellationToken
Cancellation token.
Implements ValidateAsync(string, CancellationToken)
Returns
System.Threading.Tasks.Task<System.Nullable<NonceValidationFailure>>
null when the nonce is acceptable, otherwise a
NonceValidationFailure describing why it is not.