Table of Contents

Method AuthenticateAsync

Namespace
MailFathom.Infrastructure.Security.Passwords
Assembly
MailFathom.Infrastructure.dll

AuthenticateAsync(string, string?, string?, int, int, CancellationToken)

Judges the credential an Authorization header carried.

public Task<UserPasswordAuthenticationResult> AuthenticateAsync(string surfaceName, string? authorizationHeaderValue, string? source, int attemptsPerMinute, int maxConcurrentVerifications, CancellationToken cancellationToken)

Parameters

surfaceName string

The transport surface the request arrived on, which keeps two surfaces' attempt buckets apart.

authorizationHeaderValue string

The raw header value, or null when the request carried none.

source string

The address to bound this attempt by, or null where the caller cannot supply one that tells two callers apart — behind a reverse proxy above all, where every request reports the proxy. The login is then the whole bound, which is deliberate: a partition every caller shares is one a single guesser could empty for everybody. The login is the organization's short name in front of the username where it names one, so ACME/jan and BETA/jan are bounded apart.

attemptsPerMinute int

How many attempts the surface allows one source and one login each minute.

maxConcurrentVerifications int

How many password verifications the surface may have in flight at once, whatever logins they name.

cancellationToken CancellationToken

Cancels the credential read and the rehash that may follow a success.

Returns

Task<UserPasswordAuthenticationResult>

The credential and user that matched, or the reason the credential was refused.

Exceptions

ArgumentNullException

Thrown when surfaceName is null.

ArgumentOutOfRangeException

Thrown when attemptsPerMinute or maxConcurrentVerifications is not positive, which would refuse every request rather than bounding any.