Karta. Kantoor. Restrictions
(Karta v1.0.0)
The optional restrictions of a Kantoor key (allowed_domains,
allowed_mailboxes; nil means none) and the check of an address or a
domain against them. They are enforced by the /kantoor/v1 controllers.
Grammar (case-insensitive, stored in lower case; no other use of *):
- a domain pattern is
*(every domain),example.com(that domain only) or*.example.com(its subdomains, not the domain itself); - a mailbox pattern is
*(every address),ann@example.com, or*@example.com(every local part); the part after the@is a domain pattern.
An address is allowed when it matches allowed_domains (when set) and
allowed_mailboxes (when set). A domain is allowed when it matches
allowed_domains and, when allowed_mailboxes is set, at least one
mailbox pattern could match an address at it. Karta does not interpret
the local part in any other way: no + tags, no partial wildcards.
Summary
Functions
May the key touch this address? (An address without an @ never.)
May the key touch every recipient and sender of this message? (nil addresses are ignored.)
May the key touch (list, attach to) this domain?
Does domain match the domain pattern?
The restrictions as LIKE patterns for lower(address) in SQL, for
listings (Karta.Kantoor.Messages.list/2): nil for a restriction that
is not set, otherwise a list of which an address must match one. They
select the same addresses as address_allowed?/2.
True when the key has any restriction.
True when pattern is a valid pattern of kind.
Validates (and lower-cases) the patterns in field; kind is :domain or :mailbox.
Functions
May the key touch this address? (An address without an @ never.)
May the key touch every recipient and sender of this message? (nil addresses are ignored.)
May the key touch (list, attach to) this domain?
Does domain match the domain pattern?
The restrictions as LIKE patterns for lower(address) in SQL, for
listings (Karta.Kantoor.Messages.list/2): nil for a restriction that
is not set, otherwise a list of which an address must match one. They
select the same addresses as address_allowed?/2.
True when the key has any restriction.
True when pattern is a valid pattern of kind.
@spec validate(Ecto.Changeset.t(), atom(), :domain | :mailbox) :: Ecto.Changeset.t()
Validates (and lower-cases) the patterns in field; kind is :domain or :mailbox.