Table of Contents

Method ProvisionApiKeyAsync

Namespace
MailFathom.Application.Access.Credentials
Assembly
MailFathom.Application.dll

ProvisionApiKeyAsync(UserId, IReadOnlyList<MailFathomPermission>?, UserCredentialReach, CancellationToken)

Draws a key one of a user's clients presents, and provisions the credential it resolves.

public Task<UserCredentialProvisioning> ProvisionApiKeyAsync(UserId user, IReadOnlyList<MailFathomPermission>? permissions, UserCredentialReach reach, CancellationToken cancellationToken)

Parameters

user UserId

The user the credential authenticates.

permissions IReadOnlyList<MailFathomPermission>

The names the credential narrows its user's grant to, or null to name none and hold what the user holds.

reach UserCredentialReach

On which endpoints, and from which networks, the credential may be presented.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<UserCredentialProvisioning>

What the act did, and the key to report where it was performed.

Remarks

The key is drawn here rather than accepted from the request, so nothing outside this deployment decides how much entropy a credential carries, and it is reported back because this is the one moment it exists.

Exceptions

ArgumentException

Thrown when user names nobody or the grant names something a user-facing credential cannot hold.

PrincipalNotAuthorizedException

Thrown when the caller holds AdminCredentialsWrite at no scope, does not hold a name the user holds widely enough, or is not the root while the user holds a role listing a pattern.