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
surfaceNamestringThe transport surface the request arrived on, which keeps two surfaces' attempt buckets apart.
authorizationHeaderValuestringThe raw header value, or null when the request carried none.
sourcestringThe 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/janandBETA/janare bounded apart.attemptsPerMinuteintHow many attempts the surface allows one source and one login each minute.
maxConcurrentVerificationsintHow many password verifications the surface may have in flight at once, whatever logins they name.
cancellationTokenCancellationTokenCancels 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
surfaceNameis null.- ArgumentOutOfRangeException
Thrown when
attemptsPerMinuteormaxConcurrentVerificationsis not positive, which would refuse every request rather than bounding any.