Table of Contents

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
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

provider IDataProtectionProvider

The host's data protection, whose key ring every instance must share.

time TimeProvider

The clock a message's expiry is read against.

lifetime TimeSpan

How long a message can be read after it is written.

logger ILogger<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

string

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

id string
cancellationToken CancellationToken

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

message TModel
cancellationToken CancellationToken

Returns

Task<string>

Exceptions

ArgumentNullException

message is null.