Karta. Auth
(Karta v1.0.0)
Authentication of received mail: SPF (Karta.Auth.SPF) for the MAIL
FROM and HELO identities, every DKIM signature
(Karta.Auth.DKIM.Verifier), DMARC (Karta.Auth.DMARC) for each
author domain and the ARC chain (Karta.Auth.ARC), together as
Karta.Auth.Results.
verify/3 runs them one after the other in a process of its own with a
time limit (:timeout, default 20 seconds): no check (SPF, DKIM, DMARC
or ARC) starts a lookup after it, and when the whole check has not
finished a little later, it is given up and every result is a
temperror. A crash in the checks gives the same. A temperror never
refuses mail. The process ends with its caller: when the connection
that asked is gone, nobody is left to answer, so the check stops. Given
{:file, path}, that process reads the message itself, so the caller
never holds it in memory; the checks share that one copy.
The author domains are the domains of the mailboxes of every From:
field, in A-label form. A message with none gets a DMARC permerror
(no_author); one with more than 5 (a message that names many authors
to slip a forged one past DMARC) a permerror (too_many_authors)
without any lookup (RFC 9989 §11.5).
Trusted ARC sealers. A DMARC fail is accepted anyway (its
override is :arc; the result stays fail) when the ARC chain
passes, the newest ARC set was sealed by a domain in :trusted_sealers
(exactly that domain), and that set's ARC-Authentication-Results say
dmarc=pass for the same author domain (header.from). Results that
claim Karta's own authserv-id are never taken from a message, whoever
sealed them. The list is empty unless configured (config :karta, Karta.Auth, arc_trusted_sealers:): only an operator decides whose
word to take. ARC runs after DMARC, within the same time limit, so a
long chain can delay nothing but itself.
refusal/1 says whether the results call for refusing the message;
field/2 gives its Authentication-Results field; to_map/1 the
results as stored with the message and shown by the API.
Options: :dns (options for Karta.DNS.lookup/3), :timeout
(milliseconds), :now (Unix seconds), :receiver (the receiving
host's name, for SPF explanations), :authserv_id (Karta's) and
:trusted_sealers (domains; default the configured list).
Summary
Types
The SMTP envelope: the client's address, its HELO name and the sender (nil for the null sender).
Functions
The Authentication-Results field for results under authserv_id.
Why the message should be refused, or nil: {:dmarc, domain} when
DMARC fails for an author domain whose owner asks for rejection (not in
test mode) and no trusted ARC sealer vouches for it, or
:too_many_authors. Nothing else refuses: not an SPF
fail alone (forwarded mail fails SPF and may still pass DMARC with
DKIM; RFC 9989 §7.1), not a quarantine policy, never a temperror.
The results as plain data (string keys, without empty values), as stored with the message and shown by the API.
Checks message (its bytes as received, or {:file, path}) sent with
envelope.
Types
@type envelope() :: %{ ip: :inet.ip_address(), helo: String.t() | nil, mail_from: String.t() | nil }
The SMTP envelope: the client's address, its HELO name and the sender (nil for the null sender).
Functions
@spec field(Karta.Auth.Results.t(), String.t()) :: binary()
The Authentication-Results field for results under authserv_id.
@spec refusal(Karta.Auth.Results.t()) :: {:dmarc, String.t()} | :too_many_authors | nil
Why the message should be refused, or nil: {:dmarc, domain} when
DMARC fails for an author domain whose owner asks for rejection (not in
test mode) and no trusted ARC sealer vouches for it, or
:too_many_authors. Nothing else refuses: not an SPF
fail alone (forwarded mail fails SPF and may still pass DMARC with
DKIM; RFC 9989 §7.1), not a quarantine policy, never a temperror.
@spec to_map(Karta.Auth.Results.t()) :: map()
The results as plain data (string keys, without empty values), as stored with the message and shown by the API.
@spec verify(binary() | {:file, Path.t()}, envelope(), keyword()) :: Karta.Auth.Results.t()
Checks message (its bytes as received, or {:file, path}) sent with
envelope.