TenantReplayCache Class
Keeps the identifiers of each tenant's single-use tokens - client assertions, DPoP proofs, bearer grants - in a space of its own.
public sealed class TenantReplayCache : Abblix.Jwt.ReplayPrevention.IReplayCacheInheritance System.Object → TenantReplayCache
Implements IReplayCache
Remarks
The identifier is chosen by the client, so two tenants' clients can present the same one, and without this the first tenant to see it would refuse the other's genuine token as a replay.
A reservation made outside any tenant keeps to the shared space rather than being refused, unlike stored entities: this cache is shared with the receivers of security event tokens a host may run beside the server, which work outside any tenant, and every tenant's reservation lies in its own space, so the two never meet.
Constructors
TenantReplayCache(IReplayCache, ITenantAccessor) Constructor
Keeps the identifiers of each tenant's single-use tokens - client assertions, DPoP proofs, bearer grants - in a space of its own.
public TenantReplayCache(Abblix.Jwt.ReplayPrevention.IReplayCache inner, Abblix.Oidc.Server.Features.MultiTenancy.ITenantAccessor tenantAccessor);Parameters
inner IReplayCache
tenantAccessor ITenantAccessor
Remarks
The identifier is chosen by the client, so two tenants' clients can present the same one, and without this the first tenant to see it would refuse the other's genuine token as a replay.
A reservation made outside any tenant keeps to the shared space rather than being refused, unlike stored entities: this cache is shared with the receivers of security event tokens a host may run beside the server, which work outside any tenant, and every tenant's reservation lies in its own space, so the two never meet.
Methods
TenantReplayCache.ReleaseAsync(string, CancellationToken) Method
Gives back a reservation, so the same identifier reads as fresh again.
public System.Threading.Tasks.Task ReleaseAsync(string identifier, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));Parameters
identifier System.String
The value that was reserved.
cancellationToken System.Threading.CancellationToken
Cancels the cache round trip.
Implements ReleaseAsync(string, CancellationToken)
Returns
Remarks
For the caller whose own TryReserveAsync(string, DateTimeOffset, CancellationToken) answered true and whose work on that token then failed: without it a retry of the token is refused as a replay of work that never happened. Any other caller that releases an identifier opens it to replay.
TenantReplayCache.TryReserveAsync(string, DateTimeOffset, CancellationToken) Method
Reserves an identifier, answering whether this is its first sighting.
public System.Threading.Tasks.Task<bool> TryReserveAsync(string identifier, System.DateTimeOffset expiresAt, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));Parameters
identifier System.String
What identifies the token. A profile whose identifier is unique only within a scope composes that scope into the value it passes - a SET's "jti" is unique per event feed (RFC 8417 Section 2.2), so its receiver reserves the issuer and the identifier together.
expiresAt System.DateTimeOffset
When the identifier stops being worth remembering, which is the last moment a replay of this token could still pass the caller's own freshness checks. Forgetting earlier would let that token replay; the implementation is free to remember longer.
cancellationToken System.Threading.CancellationToken
Cancels the cache round trip.
Implements TryReserveAsync(string, DateTimeOffset, CancellationToken)
Returns
System.Threading.Tasks.Task<System.Boolean>
True when the identifier was newly reserved and the token is therefore fresh; false when
it was already there, which is a replay.