Karta. Webhooks. PostalKey
(Karta v1.0.0)
The key of one organisation that signs its requests in Postal's format:
the requests of its webhooks and of its inbound HTTP endpoints. A key
belongs to one organisation, so a request signed for one organisation's
receiver does not verify with another organisation's key
(Karta.Webhooks.SigningKey).
Receivers get the public key at the organisation's own JWK set, in the shape Postal serves it:
{"keys": [{"kty": "RSA", "n": "...", "e": "AQAB", "use": "sig",
"alg": "RS256", "kid": "..."}]}The set holds the active key and the keys retired in the last week. Its
address holds a token (token/1) that is unguessable and stays the same
when the key is rotated; it names no organisation, and the set holds
public keys only. kid is the SHA-256, in hexadecimal, of the public key
(PKCS #1 DER), as Postal's JWT library computes it.
A DNS record of the key (dns_record/1) is also available, in the form
Postal prints for its own (v=DKIM1; t=s; h=sha256; p=<public key>);
Karta does not publish it.
Lifecycle. The key is generated (RSA, 2048 bits) the first time it is
needed (active!/1). rotate/1 replaces it with a new one; the old one
is retired, and published for a week. The private key is decrypted from
the vault only to sign, and is never shown.
Summary
Functions
The organisation's active key, or nil while there is none.
The organisation's active key; one is generated when there is none.
The DNS record of a key, as Postal prints its own (postal default-dkim-record): v=DKIM1; t=s; h=sha256; p=<SubjectPublicKeyInfo, base64>;.
A key's public JWK (RS256, for signatures).
The organisation's JWK set, as Postal serves it.
The path of the JWK set of the organisation whose key this is, without the host.
A key's id: the SHA-256 of its public key (PKCS #1 DER), in hexadecimal.
The organisation whose active key has this address token, or nil.
The organisation's keys whose public keys are published at now: the active one first.
Replaces the organisation's active key with a new one; the old one is retired.
Functions
@spec active(Ecto.UUID.t()) :: Karta.Webhooks.SigningKey.t() | nil
The organisation's active key, or nil while there is none.
@spec active!(Ecto.UUID.t()) :: Karta.Webhooks.SigningKey.t()
The organisation's active key; one is generated when there is none.
@spec dns_record(Karta.Auth.DKIM.Key.t()) :: String.t()
The DNS record of a key, as Postal prints its own (postal default-dkim-record): v=DKIM1; t=s; h=sha256; p=<SubjectPublicKeyInfo, base64>;.
@spec jwk(Karta.Auth.DKIM.Key.t()) :: Jason.OrderedObject.t()
A key's public JWK (RS256, for signatures).
@spec jwks(Ecto.UUID.t(), DateTime.t()) :: Jason.OrderedObject.t()
The organisation's JWK set, as Postal serves it.
@spec jwks_path(Karta.Webhooks.SigningKey.t() | String.t()) :: String.t()
The path of the JWK set of the organisation whose key this is, without the host.
@spec kid(Karta.Auth.DKIM.Key.t()) :: String.t()
A key's id: the SHA-256 of its public key (PKCS #1 DER), in hexadecimal.
@spec organisation_by_token(String.t()) :: Ecto.UUID.t() | nil
The organisation whose active key has this address token, or nil.
@spec published(Ecto.UUID.t(), DateTime.t()) :: [Karta.Webhooks.SigningKey.t()]
The organisation's keys whose public keys are published at now: the active one first.
@spec rotate(Ecto.UUID.t()) :: {:ok, Karta.Webhooks.SigningKey.t()}
Replaces the organisation's active key with a new one; the old one is retired.