Table of Contents

Class CachingClientStore<T>

Namespace
Fdyay.IdentityServer.Stores
Assembly
Fdyay.IdentityServer.Core.dll

Holds what a client store says about a client, for a duration, in a HybridCache.

public sealed class CachingClientStore<T> : IClientStore where T : IClientStore

Type Parameters

T
Inheritance
CachingClientStore<T>
Implements
Inherited Members

Remarks

Duende 8.0.1's CachingClientStore<T>, measured: a client is held by its id with an absolute expiration, in the HybridCache keyed ConfigurationStoreCache — the host's, when it registers one, and otherwise an in-memory one private to the process. AddClientStoreCache<T> puts it in front of the validating store, so what is held has been validated.

An unknown or refused client is not held, as Duende holds neither: the store is asked again on the next request naming it, so a client added to the store works on its first request, and a refused one is logged and raises its event every time it is asked for. The cost is that a caller naming client ids nobody registered reaches the store each time, as it does without the cache.

An edit to a client reaches this server within the duration, not at once — a disabled client, a removed secret or redirect URI included. GetAllClientsAsync(CancellationToken) is not cached, as Duende's is not: an enumeration is the host's own, and reads the store.

Takes its duration as an argument, from AddClientStoreCache<T>(duration), where Duende reads CachingOptions.ClientStoreExpiration: this server has no Caching group, and puts a cache's duration where the cache is switched on, as AddCorsPolicyCache(duration) does.

Constructors

CachingClientStore(T, HybridCache, TimeSpan)

A cache in front of inner, holding each client it finds for duration.

public CachingClientStore(T inner, HybridCache cache, TimeSpan duration)

Parameters

inner T

The store asked on a miss — in the registration AddClientStoreCache<T> makes, the validating store.

cache HybridCache

The HybridCache the clients are held in.

duration TimeSpan

How long a client is held, from when it was read; an absolute expiration.

Exceptions

ArgumentOutOfRangeException

duration is zero or negative.

Methods

FindClientByIdAsync(string, CancellationToken)

Finds a client by id, or returns null if not found.

public Task<Client?> FindClientByIdAsync(string clientId, CancellationToken cancellationToken = default)

Parameters

clientId string
cancellationToken CancellationToken

Returns

Task<Client>

Remarks

From the cache while held; otherwise from the inner store, and held only when the inner store found one.

GetAllClientsAsync(CancellationToken)

Every client in the store, as a stream. Duende's.

public IAsyncEnumerable<Client> GetAllClientsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

IAsyncEnumerable<Client>

Remarks

For a host's own enumeration — an administration page, an audit, a bulk change — rather than for a protocol request, which always names its client. Nothing on a request path here enumerates, as nothing in Duende does.