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
userUserIdThe user the credential authenticates.
permissionsIReadOnlyList<MailFathomPermission>The names the credential narrows its user's grant to, or null to name none and hold what the user holds.
reachUserCredentialReachOn which endpoints, and from which networks, the credential may be presented.
cancellationTokenCancellationTokenCancels 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
usernames 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.