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
storeIServerSideSessionStoreWhere the session rows are kept.
dataProtectionIDataProtectionProviderProtects each ticket before it is written to its row.
timeTimeProviderThe clock a session's creation, renewal and expiry are read against.
handlesIHandleGenerationServiceGenerates the key each new session is stored under, which is what the cookie carries.
Exceptions
- ArgumentNullException
dataProtectionis 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
filterSessionFiltercancellationTokenCancellationToken
Returns
Remarks
An expired session is not one, as RetrieveAsync treats it.
Exceptions
- ArgumentNullException
filteris null.
RemoveAsync(string)
Deletes the session held under key.
public Task RemoveAsync(string key)
Parameters
keystringThe 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
keystringThe session's key.
ticketAuthenticationTicketThe renewed ticket.
Returns
Exceptions
- ArgumentNullException
ticketis 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
keystringThe 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
ticketAuthenticationTicketThe authentication ticket to keep.
Returns
Exceptions
- ArgumentNullException
ticketis null.- InvalidOperationException
The ticket's principal carries no subject id.