Skip to main content

DistributedJwtReplayCache Class

Abblix.Oidc.Server

Abblix.Oidc.Server.Features.JwtBearer

DistributedJwtReplayCache Class

Backward-compat adapter from the legacy two-step IJwtReplayCache shape onto the canonical single-call TryAddAsync(string, Nullable<DateTimeOffset>). Delegates via composition rather than inheritance so the deprecated contract stays type-isolated from the canonical one.

public sealed class DistributedJwtReplayCache : Abblix.Oidc.Server.Features.JwtBearer.IJwtReplayCache

Inheritance System.Object → DistributedJwtReplayCache

Implements IJwtReplayCache

Remarks

IsReplayedAsync(string) probes the cache in read-only mode (no jti is recorded), and MarkAsUsedAsync(string, Nullable<DateTimeOffset>) issues the canonical TryAddAsync(string, Nullable<DateTimeOffset>). Concurrent presenters of the same jti can therefore both pass the read before either reaches the write — this is the same TOCTOU window the legacy API has always exposed and is the reason new code should consume TryAddAsync directly.

Constructors

DistributedJwtReplayCache(IJwtReplayCache) Constructor

Backward-compat adapter from the legacy two-step IJwtReplayCache shape onto the canonical single-call TryAddAsync(string, Nullable<DateTimeOffset>). Delegates via composition rather than inheritance so the deprecated contract stays type-isolated from the canonical one.

public DistributedJwtReplayCache(Abblix.Oidc.Server.Features.ReplayPrevention.IJwtReplayCache canonical);

Parameters

canonical IJwtReplayCache

Remarks

IsReplayedAsync(string) probes the cache in read-only mode (no jti is recorded), and MarkAsUsedAsync(string, Nullable<DateTimeOffset>) issues the canonical TryAddAsync(string, Nullable<DateTimeOffset>). Concurrent presenters of the same jti can therefore both pass the read before either reaches the write — this is the same TOCTOU window the legacy API has always exposed and is the reason new code should consume TryAddAsync directly.

Methods

DistributedJwtReplayCache.IsReplayedAsync(string) Method

Checks if a JWT with the specified JTI has already been used.

public System.Threading.Tasks.Task<bool> IsReplayedAsync(string jti);

Parameters

jti System.String

The JWT ID (jti claim) to check.

Implements IsReplayedAsync(string)

Returns

System.Threading.Tasks.Task<System.Boolean>
A task that completes with true if the JWT has already been used (replay detected); false if this is the first time the JWT is being presented.

DistributedJwtReplayCache.MarkAsUsedAsync(string, Nullable<DateTimeOffset>) Method

Marks a JWT as used by storing its JTI in the cache until the specified expiration time.

public System.Threading.Tasks.Task MarkAsUsedAsync(string jti, System.Nullable<System.DateTimeOffset> expiresAt);

Parameters

jti System.String

The JWT ID (jti claim) to mark as used.

expiresAt System.Nullable<System.DateTimeOffset>

The time at which the JWT expires. The JTI will be stored until this time plus a small buffer. If null, a default expiration will be used.

Implements MarkAsUsedAsync(string, Nullable<DateTimeOffset>)

Returns

System.Threading.Tasks.Task
A task that completes when the JTI has been stored.