Kantoor.Karta.Keys (Kantoor v1.0.0)

The Karta key of a mail domain.

Kantoor talks to one Karta, but each mail domain may live in its own Karta organisation (a Balie account gets one organisation per customer). A domain attached through the provisioning API can bring the key of that organisation; it is stored encrypted on the domain (Kantoor.Vault) and used for the calls about that domain: attaching its route, switching the route, sending from it and fetching its messages. A domain without a key uses the instance key (KANTOOR_KARTA_API_KEY, Kantoor.Karta.Settings).

The lookups here never return a key for a domain that has none: the caller falls back to the instance key, so an installation with one organisation works as before.

Summary

Functions

The domain name of a mailbox, or nil.

The domain name a message belongs to (through its mailbox), or nil.

The domain's own Karta key, decrypted, or :none (no key stored for it). A stored value that will not decrypt is :error: the key is there but useless, and falling back to the instance key would ask the wrong organisation.

Functions

domain_of_mailbox(mailbox_id)

@spec domain_of_mailbox(Ecto.UUID.t() | nil) :: String.t() | nil

The domain name of a mailbox, or nil.

domain_of_message(message_id)

@spec domain_of_message(Ecto.UUID.t() | nil) :: String.t() | nil

The domain name a message belongs to (through its mailbox), or nil.

for_domain(name)

@spec for_domain(String.t() | nil) :: {:ok, String.t()} | :none | :error

The domain's own Karta key, decrypted, or :none (no key stored for it). A stored value that will not decrypt is :error: the key is there but useless, and falling back to the instance key would ask the wrong organisation.