Table of Contents

Method RenewAsync

Namespace
MailFathom.Application.Access.Sessions
Assembly
MailFathom.Application.dll

RenewAsync(string, ReadOnlyMemory<byte>, MintedClientSessionRow, DateTimeOffset, CancellationToken)

Replaces a live session with a new one, carrying its grant forward, so one sign-in holds one live token however often a client renews.

Task<ClientSessionGrant?> RenewAsync(string identifier, ReadOnlyMemory<byte> secretDigest, MintedClientSessionRow replacement, DateTimeOffset renewableFrom, CancellationToken cancellationToken)

Parameters

identifier string

The public half of the presented token.

secretDigest ReadOnlyMemory<byte>

The digest of the presented secret, which the removal is guarded by.

replacement MintedClientSessionRow

The identifier, the digest, and the expiry the caller drew for the replacement.

renewableFrom DateTimeOffset

The instant the presented session must not already have expired at.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<ClientSessionGrant>

What the replacement admits, or null where the presented session no longer authenticates or the credential behind it no longer admits one.

Remarks

Removing the presented row and inserting the replacement in one transaction is what leaves exactly one live session where two requests present one token, whichever replica each of them reaches — settled by PostgreSQL rather than by a check either of them makes between two statements.

The removal carries the digest in its own condition rather than removing the row and judging the secret afterwards, because a session survives being presented: a removal keyed on the identifier alone would let anybody writing the half of a token that is not a secret end somebody else's session.

Exceptions

ClientSessionStoreUnavailableException

Thrown when the sessions could not be reached, which the caller answers as unavailable rather than by refusing the renewal.