Table of Contents

Class InMemoryReplayCache

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.Core.dll

An in-process replay cache.

public sealed class InMemoryReplayCache : IReplayCache
Inheritance
InMemoryReplayCache
Implements
Inherited Members

Remarks

Development-grade, and the limitation is the one that matters for what this protects: a second instance has its own cache, so a proof or a signed request replayed against a different instance is not recognised as one. A multi-instance host wants a shared implementation, the same way it wants a shared session store.

Entries are swept when the cache is read rather than on a timer. The cache is only ever consulted on the path that adds to it, so a sweep on read happens exactly as often as it is needed and never when the feature is unused.

Constructors

InMemoryReplayCache(TimeProvider)

An in-process replay cache.

public InMemoryReplayCache(TimeProvider time)

Parameters

time TimeProvider

The clock an entry's expiry is checked against.

Methods

AddAsync(string, string, DateTimeOffset, CancellationToken)

Records handle as used, until expiration.

public Task AddAsync(string purpose, string handle, DateTimeOffset expiration, CancellationToken cancellationToken = default)

Parameters

purpose string
handle string
expiration DateTimeOffset
cancellationToken CancellationToken

Returns

Task

ExistsAsync(string, string, CancellationToken)

Whether handle has been recorded and has not yet expired.

public Task<bool> ExistsAsync(string purpose, string handle, CancellationToken cancellationToken = default)

Parameters

purpose string
handle string
cancellationToken CancellationToken

Returns

Task<bool>