Table of Contents

Class DynamicProviderExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Fdyay.IdentityServer.AspNetCore.dll

Registers identity providers a host can change without restarting.

public static class DynamicProviderExtensions
Inheritance
DynamicProviderExtensions
Inherited Members

Fields

ConfigurationStoreCacheKey

The service key of the HybridCache the identity-provider store cache uses. Duende's.

public const string ConfigurationStoreCacheKey = "ConfigurationStoreCache"

Field Value

string

Remarks

A host brings its own by registering a HybridCache under this key, before or after AddIdentityProviderStoreCache<T>(IIdentityServerBuilder) — Microsoft's, with AddKeyedHybridCache, is the way to a distributed second level shared by every instance. Without one, an in-memory cache private to this process is used, which is what Duende's default amounts to when no distributed cache is registered: each instance asks its store again once the duration has passed.

DefaultIdentityProviderCacheDuration

How long AddIdentityProviderStoreCache<T>(IIdentityServerBuilder) holds a provider: Duende's 60 minutes.

public static readonly TimeSpan DefaultIdentityProviderCacheDuration

Field Value

TimeSpan

Methods

AddDynamicProviderType<THandler, TOptions, TIdentityProvider>(IIdentityServerBuilder, string)

Registers a kind of provider a stored row may name, and the plumbing that serves it.

public static IIdentityServerBuilder AddDynamicProviderType<THandler, TOptions, TIdentityProvider>(this IIdentityServerBuilder builder, string type) where THandler : class, IAuthenticationHandler where TOptions : AuthenticationSchemeOptions, new() where TIdentityProvider : IdentityProvider

Parameters

builder IIdentityServerBuilder
type string

Returns

IIdentityServerBuilder

Type Parameters

THandler
TOptions
TIdentityProvider

Remarks

The handler is registered so the framework can construct it when a scheme names its type, and an IConfigureOptions<TOptions> is added so its named options are built from the stored row. Both are what a static registration would have done for a scheme known at startup.

AddDynamicProviders(IIdentityServerBuilder, Action<DynamicProviderOptions>?)

Adds the dynamic provider mechanism, with no provider kinds registered yet.

public static IIdentityServerBuilder AddDynamicProviders(this IIdentityServerBuilder builder, Action<DynamicProviderOptions>? configureOptions = null)

Parameters

builder IIdentityServerBuilder
configureOptions Action<DynamicProviderOptions>

Returns

IIdentityServerBuilder

Remarks

On its own this changes nothing a host can observe: a mechanism with no kinds registered can serve no stored row, and a store with no rows adds no schemes. Both halves are the caller's — add a kind with AddDynamicProviderType<THandler, TOptions, TIdentityProvider>(IIdentityServerBuilder, string) and a store with AddInMemoryIdentityProviders(IIdentityServerBuilder, IEnumerable<IdentityProvider>) or one of your own.

AddIdentityProviderStoreCache<T>(IIdentityServerBuilder)

Registers a custom IIdentityProviderStore, cached for Duende's 60 minutes.

public static IIdentityServerBuilder AddIdentityProviderStoreCache<T>(this IIdentityServerBuilder builder) where T : class, IIdentityProviderStore

Parameters

builder IIdentityServerBuilder

Returns

IIdentityServerBuilder

Type Parameters

T

AddIdentityProviderStoreCache<T>(IIdentityServerBuilder, TimeSpan)

Registers a custom IIdentityProviderStore, validated and then cached.

public static IIdentityServerBuilder AddIdentityProviderStoreCache<T>(this IIdentityServerBuilder builder, TimeSpan duration) where T : class, IIdentityProviderStore

Parameters

builder IIdentityServerBuilder

The builder.

duration TimeSpan

How long a provider, and the list of them, is held before the store is asked again. An edit to a row reaches this server within it. As with AddCorsPolicyCache, no duration disables the cache: a host that does not want one calls AddIdentityProviderStore<T>(IIdentityServerBuilder).

Returns

IIdentityServerBuilder

Type Parameters

T

AddIdentityProviderStore<T>(IIdentityServerBuilder)

Registers a custom IIdentityProviderStore implementation, validated as it is read.

public static IIdentityServerBuilder AddIdentityProviderStore<T>(this IIdentityServerBuilder builder) where T : class, IIdentityProviderStore

Parameters

builder IIdentityServerBuilder

Returns

IIdentityServerBuilder

Type Parameters

T

Remarks

The store is registered as itself and answers as IIdentityProviderStore behind ValidatingIdentityProviderStore<T>, as Duende 8.0.1 registers it. Duende puts one more decorator outside that, NonCachingIdentityProviderStore<T>, to drop a changed row's handler options; that is DynamicAuthenticationSchemeProvider's work here, so a store registered by hand gets it too.

AddInMemoryIdentityProviders(IIdentityServerBuilder, IEnumerable<IdentityProvider>)

Registers an IIdentityProviderStore over a fixed list.

public static IIdentityServerBuilder AddInMemoryIdentityProviders(this IIdentityServerBuilder builder, IEnumerable<IdentityProvider> providers)

Parameters

builder IIdentityServerBuilder
providers IEnumerable<IdentityProvider>

Returns

IIdentityServerBuilder