Table of Contents

Class InMemoryServerSideSessionStore

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

In-memory server-side session store. Intended for development and testing.

public class InMemoryServerSideSessionStore : IServerSideSessionStore
Inheritance
InMemoryServerSideSessionStore
Implements
Inherited Members

Remarks

Sessions do not survive a restart here, and are not shared between instances — so a host running more than one process needs a real store, or a user will appear signed out whenever the load balancer moves them.

Constructors

InMemoryServerSideSessionStore()

A store on the system clock.

public InMemoryServerSideSessionStore()

InMemoryServerSideSessionStore(TimeProvider)

A store on the server's clock. Duende's constructor.

public InMemoryServerSideSessionStore(TimeProvider time)

Parameters

time TimeProvider

The clock the expiry sweep judges Expires against.

Remarks

Since 0.175.0, and the one the container builds; until then the sweep read UtcNow.

Methods

CreateSessionAsync(ServerSideSession, CancellationToken)

Stores a session under its Key, replacing any already held under that key.

public Task CreateSessionAsync(ServerSideSession session, CancellationToken cancellationToken = default)

Parameters

session ServerSideSession

The session.

cancellationToken CancellationToken

Cancels the write.

Returns

Task

DeleteSessionAsync(string, CancellationToken)

Removes the session stored under a key. A key with nothing stored under it is not an error.

public Task DeleteSessionAsync(string key, CancellationToken cancellationToken = default)

Parameters

key string

The session's Key.

cancellationToken CancellationToken

Cancels the removal.

Returns

Task

DeleteSessionsAsync(SessionFilter, CancellationToken)

Ends every session matching the filter.

public Task DeleteSessionsAsync(SessionFilter filter, CancellationToken cancellationToken = default)

Parameters

filter SessionFilter
cancellationToken CancellationToken

Returns

Task

GetAndRemoveExpiredSessionsAsync(int, CancellationToken)

Removes sessions past their expiry and returns them, so a caller can act on what it removed.

public Task<IReadOnlyCollection<ServerSideSession>> GetAndRemoveExpiredSessionsAsync(int count, CancellationToken cancellationToken = default)

Parameters

count int
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<ServerSideSession>>

Remarks

Returns rather than merely deletes because an expired session still has clients that were signed in to it, and they are owed a back-channel logout. A sweep that deleted silently would leave every relying party believing a session that ended hours ago is still live.

GetSessionAsync(string, CancellationToken)

The session stored under a key, or null.

public Task<ServerSideSession?> GetSessionAsync(string key, CancellationToken cancellationToken = default)

Parameters

key string

The session's Key.

cancellationToken CancellationToken

Cancels the read.

Returns

Task<ServerSideSession>

The session, or null when none is stored under that key.

GetSessionsAsync(SessionFilter, CancellationToken)

Every session matching the filter.

public Task<IReadOnlyCollection<ServerSideSession>> GetSessionsAsync(SessionFilter filter, CancellationToken cancellationToken = default)

Parameters

filter SessionFilter
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<ServerSideSession>>

QuerySessionsAsync(SessionQuery, CancellationToken)

A page of sessions, for an administrative list.

public Task<QueryResult<ServerSideSession>> QuerySessionsAsync(SessionQuery query, CancellationToken cancellationToken = default)

Parameters

query SessionQuery
cancellationToken CancellationToken

Returns

Task<QueryResult<ServerSideSession>>

UpdateSessionAsync(ServerSideSession, CancellationToken)

Replaces the session stored under its Key, or stores it when none is.

public Task UpdateSessionAsync(ServerSideSession session, CancellationToken cancellationToken = default)

Parameters

session ServerSideSession

The session as it now stands.

cancellationToken CancellationToken

Cancels the write.

Returns

Task