Kantoor. Provisioning. Users
(Kantoor v1.0.0)
Users, their mailbox grants and their identities for the provisioning API. See
Kantoor.Provisioning for tenancy, idempotency and suspension.
How a provisioned user signs in
Kantoor has no local passwords for the web interface: people sign in through the identity provider (OIDC). A user is made one of two ways:
- with
oidc_sub(the provider's subject for this person): the user is linked from the start and can sign in at once; - without it: the user is invited. The first sign-in whose verified email
(
email_verified: true) is the user's email links it. Nothing else ever links an account to a person by email.
IMAP, POP3 and DAV use app passwords the user makes after signing in; the API does not
make or return passwords. Users made here are always plain users (role: "user"): an
instance administrator is an admin decision (Kantoor.Admin), and the API cannot
suspend or delete one.
Summary
Functions
Deletes the user with its app passwords, grants, identities, calendars and contacts.
Mail stays with the mailboxes. Deleting what is not there (or not yours) is :ok.
An admin cannot be deleted through the API.
Removes the identity on this address. Removing what is not there is :ok.
The operator's user by reference, with its domain; nil otherwise.
Lets the user open the mailbox with this address. Both must be in the same domain,
and the domain yours. Granting twice is :ok.
The operator's users ordered by email. Options: :domain_ref, :state ("active"
or "suspended"), :limit (default 100, at most 500), :after (the last
email of the previous page). Returns {rows, next}.
The user's sending identities.
The mailboxes the user may open, ordered by address.
Creates the user ref (attrs: domain_ref, email, optional display_name,
locale, role, oidc_sub) or returns the one that exists. The email must be an
address at the domain. Creating takes a seat: the domain's max_users is checked
under a lock on the domain, so concurrent creations cannot exceed it.
Makes the user a sending identity on a mailbox address it may open (attrs: name,
reply_to, is_default), or returns the one that exists. Kantoor has no aliases:
an identity is a name on a mailbox address.
Resumes a user that was suspended through the API. A user disabled by an admin is
:disabled_by_admin, one whose domain is suspended is :domain_suspended; an active
user is returned as it is.
Takes the grant away. Revoking what is not granted is :ok.
Suspends a user: it cannot sign in anywhere and its sessions end; nothing is deleted.
Suspending a suspended user is :ok. An admin cannot be suspended through the API
(:admin_user).
Changes the user's display_name and locale (the keys in attrs).
Functions
@spec delete(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: :ok | {:error, :admin_user}
Deletes the user with its app passwords, grants, identities, calendars and contacts.
Mail stays with the mailboxes. Deleting what is not there (or not yours) is :ok.
An admin cannot be deleted through the API.
@spec delete_identity(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t()) :: :ok | {:error, :not_found}
Removes the identity on this address. Removing what is not there is :ok.
@spec get(Kantoor.ApiKeys.ApiKey.t(), term()) :: Kantoor.Accounts.User.t() | nil
The operator's user by reference, with its domain; nil otherwise.
@spec grant_mailbox(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t()) :: {:ok, Kantoor.Mailboxes.Mailbox.t()} | {:error, :not_found}
Lets the user open the mailbox with this address. Both must be in the same domain,
and the domain yours. Granting twice is :ok.
@spec list(Kantoor.ApiKeys.ApiKey.t(), keyword()) :: {[Kantoor.Accounts.User.t()], String.t() | nil}
The operator's users ordered by email. Options: :domain_ref, :state ("active"
or "suspended"), :limit (default 100, at most 500), :after (the last
email of the previous page). Returns {rows, next}.
@spec list_identities(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: {:ok, [Kantoor.Identities.Identity.t()]} | {:error, :not_found}
The user's sending identities.
@spec list_mailboxes(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: {:ok, [Kantoor.Mailboxes.Mailbox.t()]} | {:error, :not_found}
The mailboxes the user may open, ordered by address.
@spec put(Kantoor.ApiKeys.ApiKey.t(), String.t(), map()) :: {:ok, Kantoor.Accounts.User.t(), :created | :existing} | {:error, term()}
Creates the user ref (attrs: domain_ref, email, optional display_name,
locale, role, oidc_sub) or returns the one that exists. The email must be an
address at the domain. Creating takes a seat: the domain's max_users is checked
under a lock on the domain, so concurrent creations cannot exceed it.
{:ok, user, :created | :existing}, or {:error, reason}: :ref_conflict (the
reference names another user), :domain_suspended, :seat_limit_reached,
:email_taken, :sub_taken, {:invalid, field, message} or a changeset.
@spec put_identity(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t(), map()) :: {:ok, Kantoor.Identities.Identity.t(), :created | :existing} | {:error, term()}
Makes the user a sending identity on a mailbox address it may open (attrs: name,
reply_to, is_default), or returns the one that exists. Kantoor has no aliases:
an identity is a name on a mailbox address.
@spec resume(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: {:ok, Kantoor.Accounts.User.t()} | {:error, :not_found | :domain_suspended | :disabled_by_admin}
Resumes a user that was suspended through the API. A user disabled by an admin is
:disabled_by_admin, one whose domain is suspended is :domain_suspended; an active
user is returned as it is.
@spec revoke_mailbox(Kantoor.ApiKeys.ApiKey.t(), String.t(), String.t()) :: :ok | {:error, :not_found}
Takes the grant away. Revoking what is not granted is :ok.
@spec suspend(Kantoor.ApiKeys.ApiKey.t(), String.t()) :: {:ok, Kantoor.Accounts.User.t()} | {:error, :not_found | :admin_user}
Suspends a user: it cannot sign in anywhere and its sessions end; nothing is deleted.
Suspending a suspended user is :ok. An admin cannot be suspended through the API
(:admin_user).
@spec update(Kantoor.ApiKeys.ApiKey.t(), String.t(), map()) :: {:ok, Kantoor.Accounts.User.t()} | {:error, :not_found | Ecto.Changeset.t()}
Changes the user's display_name and locale (the keys in attrs).