Class ProtectedDataMessageStore<TModel>
- Namespace
- Fdyay.IdentityServer.Services
- Assembly
- Fdyay.IdentityServer.AspNetCore.dll
A message store that keeps nothing: the message, protected, is its own id. Duende's, for a farm.
public sealed class ProtectedDataMessageStore<TModel> : IMessageStore<TModel>
Type Parameters
TModel
- Inheritance
-
ProtectedDataMessageStore<TModel>
- Implements
-
IMessageStore<TModel>
- Inherited Members
Remarks
Duende 8.0.1's ProtectedDataMessageStore<T>, measured: the message serialized as JSON, protected with the
host's data protection ring under one purpose, and Base64Url-encoded as the id the store hands back; reading reverses
it, and a value that does not unprotect reads as no message, logged. Any instance sharing the ring reads what any other
wrote, which is what InMemoryMessageStore<TModel> cannot do.
Where ours differs: the message carries its expiry — this store's interface promises that an expired message reads as
none, where Duende's message carries only its creation time — and a message that cannot be written is an exception, not
a null id. Opt in with AddProtectedDataMessageStores; the in-memory store stays the default, as the error page shows
the id to the user, and this id is the size of the message.
Constructors
ProtectedDataMessageStore(IDataProtectionProvider, TimeProvider, TimeSpan, ILogger<ProtectedDataMessageStore<TModel>>)
public ProtectedDataMessageStore(IDataProtectionProvider provider, TimeProvider time, TimeSpan lifetime, ILogger<ProtectedDataMessageStore<TModel>> logger)
Parameters
providerIDataProtectionProviderThe host's data protection, whose key ring every instance must share.
timeTimeProviderThe clock a message's expiry is read against.
lifetimeTimeSpanHow long a message can be read after it is written.
loggerILogger<ProtectedDataMessageStore<TModel>>Where a message that cannot be read is reported.
Fields
Purpose
The purpose every message is protected under. Duende's string, this server's name.
public const string Purpose = "Fdyay.IdentityServer.Stores.ProtectedDataMessageStore"
Field Value
Methods
ReadAsync(string?, CancellationToken)
Reads the message with the given id, or null when the id is unknown or has expired.
public Task<TModel?> ReadAsync(string? id, CancellationToken cancellationToken = default)
Parameters
idstringcancellationTokenCancellationToken
Returns
- Task<TModel>
WriteAsync(TModel, CancellationToken)
Stores the message and returns the opaque id it can be read back with.
public Task<string> WriteAsync(TModel message, CancellationToken cancellationToken = default)
Parameters
messageTModelcancellationTokenCancellationToken
Returns
Exceptions
- ArgumentNullException
messageis null.