Karta.Auth.AuthenticationResults (Karta v1.0.0)

The Authentication-Results: header field (RFC 8601) that Karta puts on the mail it receives, and the recognition of fields that claim to be Karta's.

Writing. field/2 reports the SPF results (MAIL FROM and HELO), every DKIM signature, DMARC for each author domain and the ARC chain (arc=, with smtp.remote-ip and header.oldest-pass, RFC 8617 §6; a DMARC failure that a trusted ARC sealer's results overrode says so in its reason), under Karta's authentication service identifier (the authserv-id). Every value in it is either one of a fixed set of words or comes from DNS or the message after it was checked: domain names in their normalised ASCII form, a DKIM selector, a prefix of a signature. Anything that is not a MIME token is written as a quoted string, in which only printable ASCII is kept and " and \ are escaped, and the field is built by Karta.Mail.Headers.field/2, which refuses a line break or another control character: nothing from DNS or the message can end the field or start another. Only domains are reported, never the local part of an address, which SPF does not authenticate (§4).

Removing. A message may arrive with fields that claim Karta's authserv-id; downstream readers would trust them. ours?/2 recognises them as a reader would: the first word of the value after comments and white space, unquoted, compared without case and without a final dot. The mx listener removes every such field before it stores the message (§5).

Summary

Functions

True when an Authentication-Results value (or the part of an ARC-Authentication-Results value after its instance) claims authserv_id, read as ours?/2 reads it.

The header field, folded and ending in CRLF, for results (Karta.Auth.Results) under authserv_id.

True when field is an Authentication-Results field claiming authserv_id.

The parts of an Authentication-Results value, or of an ARC-Authentication-Results value after its instance: first the authserv-id (with its version, if any), then each result, split at the semicolons outside comments and quoted strings. Folding and runs of white space become single spaces, each part is trimmed; empty parts and a result of none (no result) are left out.

One result (method=result and ptype.property=value pairs) without its comments, as {method, result, properties}: the method, the result and the property names in lower case, quoted values unquoted; :error when it does not start with method=result.

Functions

claims?(value, authserv_id)

@spec claims?(binary(), String.t()) :: boolean()

True when an Authentication-Results value (or the part of an ARC-Authentication-Results value after its instance) claims authserv_id, read as ours?/2 reads it.

field(authserv_id, results)

@spec field(String.t(), Karta.Auth.Results.t()) :: binary()

The header field, folded and ending in CRLF, for results (Karta.Auth.Results) under authserv_id.

ours?(field, authserv_id)

@spec ours?(Karta.Mail.Header.t(), String.t()) :: boolean()

True when field is an Authentication-Results field claiming authserv_id.

parts(value)

@spec parts(binary()) :: [String.t()]

The parts of an Authentication-Results value, or of an ARC-Authentication-Results value after its instance: first the authserv-id (with its version, if any), then each result, split at the semicolons outside comments and quoted strings. Folding and runs of white space become single spaces, each part is trimmed; empty parts and a result of none (no result) are left out.

result(text)

@spec result(String.t()) ::
  {String.t(), String.t(), %{required(String.t()) => String.t()}} | :error

One result (method=result and ptype.property=value pairs) without its comments, as {method, result, properties}: the method, the result and the property names in lower case, quoted values unquoted; :error when it does not start with method=result.