Karta. RequestAuth
(Karta v1.0.0)
The extra header that authenticates Karta's requests to a receiver that cannot check a signature: a webhook's or an inbound HTTP endpoint's own header name and secret value, sent beside the format's signature, never instead of it.
A name is an HTTP token (RFC 9110 §5.6.2: letters, digits and
!#$%&'*+-.^_`|~), compared without case. Reserved names are refused:
the ones the request's framing or content needs (Host, Content-*,
Transfer-Encoding, Connection, Upgrade, TE, Trailer,
Proxy-*, User-Agent) and every format's signature headers
(webhook-*, X-Postal-Signature*, X-Twilio-Email-Event-Webhook-*,
X-Mailgun-*, X-PM-*). Authorization is refused while the URL also
carries a user name and password, which are sent in that header.
A value is printable ASCII (0x20-0x7E), at most 1024 bytes, without
white space at either end: a line break, a control character or a NUL
would end the field or start another, and Karta.NetGuard.HTTP writes
the headers as given.
What it does not protect: the body's integrity and a request sent again. A receiver that needs those checks the format's signature.
Summary
Functions
The header of a webhook or an endpoint (both have auth_header and
auth_header_value), or none.
Whether name is an HTTP header name (a token), within reason.
Whether name is one Karta sends itself, or one the request or a
format's signature needs. credentials? is true when the URL carries a
user name and password, which are sent as Authorization.
Validates the pair of auth_header and auth_header_value in a
changeset, with auth_header_remove (true: both go)
Whether value may be sent in a header.
Functions
The header of a webhook or an endpoint (both have auth_header and
auth_header_value), or none.
Whether name is an HTTP header name (a token), within reason.
Whether name is one Karta sends itself, or one the request or a
format's signature needs. credentials? is true when the URL carries a
user name and password, which are sent as Authorization.
@spec validate(Ecto.Changeset.t(), keyword()) :: Ecto.Changeset.t()
Validates the pair of auth_header and auth_header_value in a
changeset, with auth_header_remove (true: both go):
- a name without a value takes the stored value (a rename), and a new name needs a value;
- a value without a name changes the stored header's value;
auth_header_removecannot be given with either.
Options: credentials (true when the URL carries a user name and
password, which are sent as Authorization).
Whether value may be sent in a header.