Table of Contents

Class InMemorySamlSigninStateStore

Namespace
Fdyay.IdentityServer.Saml.Stores
Assembly
Fdyay.IdentityServer.Saml.dll

In-memory sign-in state store. Intended for development and single-instance hosting.

public sealed class InMemorySamlSigninStateStore : ISamlSigninStateStore
Inheritance
InMemorySamlSigninStateStore
Implements
Inherited Members

Remarks

Swept on read rather than on a timer: a state nobody came back for is only in the way of the memory it occupies, and a host that wants a bounded store provides one.

Constructors

InMemorySamlSigninStateStore(TimeProvider)

Creates an empty store.

public InMemorySamlSigninStateStore(TimeProvider time)

Parameters

time TimeProvider

The clock expiry is judged against.

Fields

Lifetime

How long a state written without an ExpiresAt is kept.

public static readonly TimeSpan Lifetime

Field Value

TimeSpan

Remarks

Until 0.145.0 every state was kept this long; the endpoints now write each one's expiry from SamlOptions.SigninStateLifetime, and this is left for a state a host stores itself without one.

Methods

PeekAsync(string, CancellationToken)

Returns the state for key without consuming it, or null if absent.

public Task<SamlSignInState?> PeekAsync(string key, CancellationToken cancellationToken = default)

Parameters

key string
cancellationToken CancellationToken

Returns

Task<SamlSignInState>

Remarks

For the login page, which needs to say which service provider is waiting and may be rendered more than once for one sign-in — a mistyped password renders it again. Consuming it there would leave the endpoint with nothing to resume when the user finally succeeds. The pushed-authorization reference on the OpenID Connect side is read the same way and for the same reason.

Exceptions

ArgumentException

key is null or empty.

StoreAsync(string, SamlSignInState, CancellationToken)

Stores state under key, an opaque reference, replacing any state already there.

public Task StoreAsync(string key, SamlSignInState state, CancellationToken cancellationToken = default)

Parameters

key string
state SamlSignInState
cancellationToken CancellationToken

Returns

Task

Remarks

Replacing is what records a denial: the state is read with PeekAsync(string, CancellationToken), given its DenialError and stored back under its key.

Exceptions

ArgumentException

key is null or empty.

ArgumentNullException

state is null.

TakeAsync(string, CancellationToken)

Atomically removes and returns the state for key, or null if absent.

public Task<SamlSignInState?> TakeAsync(string key, CancellationToken cancellationToken = default)

Parameters

key string
cancellationToken CancellationToken

Returns

Task<SamlSignInState>

Remarks

Drops every expired state first, so an expired one is absent.

Exceptions

ArgumentException

key is null or empty.