Table of Contents

Class ServerSideTicketStore

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.AspNetCore.dll

The seam that turns the session cookie into a reference to a stored session.

public class ServerSideTicketStore : IServerSideTicketStore, ITicketStore
Inheritance
ServerSideTicketStore
Implements
Inherited Members

Remarks

ITicketStore is ASP.NET Core's own hook: when the cookie handler is given one, it writes a key into the cookie and keeps the ticket here. That indirection is the entire mechanism behind revocation — a self-contained cookie is valid until it expires no matter what the server decides afterwards, while a key resolves to nothing the moment the row is gone.

Constructors

ServerSideTicketStore(IServerSideSessionStore, IDataProtectionProvider, TimeProvider, IHandleGenerationService)

Creates the store, as the container resolves it.

public ServerSideTicketStore(IServerSideSessionStore store, IDataProtectionProvider dataProtection, TimeProvider time, IHandleGenerationService handles)

Parameters

store IServerSideSessionStore

Where the session rows are kept.

dataProtection IDataProtectionProvider

Protects each ticket before it is written to its row.

time TimeProvider

The clock a session's creation, renewal and expiry are read against.

handles IHandleGenerationService

Generates the key each new session is stored under, which is what the cookie carries.

Exceptions

ArgumentNullException

dataProtection is null.

Methods

GetSessionsAsync(SessionFilter, CancellationToken)

The sessions matching filter, each with its ticket. Duende's.

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

Parameters

filter SessionFilter
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<UserSession>>

Remarks

An expired session is not one, as RetrieveAsync treats it.

Exceptions

ArgumentNullException

filter is null.

RemoveAsync(string)

Deletes the session held under key.

public Task RemoveAsync(string key)

Parameters

key string

The session's key.

Returns

Task

A task that completes when the row is deleted.

RenewAsync(string, AuthenticationTicket)

Replaces the ticket held under key, keeping the session's creation time; a revoked session is not recreated.

public Task RenewAsync(string key, AuthenticationTicket ticket)

Parameters

key string

The session's key.

ticket AuthenticationTicket

The renewed ticket.

Returns

Task

Exceptions

ArgumentNullException

ticket is null.

InvalidOperationException

The ticket's principal carries no subject id.

RetrieveAsync(string)

The ticket held under key, or null when there is no such session or it has expired.

public Task<AuthenticationTicket?> RetrieveAsync(string key)

Parameters

key string

The session's key.

Returns

Task<AuthenticationTicket>

The ticket, or null.

StoreAsync(AuthenticationTicket)

Stores ticket as a new session row under a freshly generated key.

public Task<string> StoreAsync(AuthenticationTicket ticket)

Parameters

ticket AuthenticationTicket

The authentication ticket to keep.

Returns

Task<string>

The key the cookie carries in place of the ticket.

Exceptions

ArgumentNullException

ticket is null.

InvalidOperationException

The ticket's principal carries no subject id.