Expand description
HMAC request-signing authentication plugin (hmac-auth).
Port of APISIX’s hmac-auth plugin (3.17). A client proves possession of a
shared secret_key by signing a canonical signing string built from the
request and sending the base64 signature alongside the access_key that
identifies the credential. featherbit recomputes the signature with the
matching secret and compares; a mismatch, an unknown key, a stale Date,
or a missing required signed header is rejected as 401 HMAC_INVALID
through the node’s error port.
§Wire format
The signature parameters are read from either:
- an
Authorizationheader of the formSignature keyId="<access_key>",algorithm="hmac-sha256",headers="date @request-target",signature="<base64>"(APISIX 3.17’s format —keyIdis the featherbitaccess_key), or - the discrete headers
X-HMAC-ACCESS-KEY,X-HMAC-ALGORITHM,X-HMAC-SIGNED-HEADERS(space-separated), andX-HMAC-SIGNATURE.
The Date header (RFC 1123 / GMT) carries the timestamp checked against
clock_skew.
§Signing string
Mirrors APISIX’s generate_signature: the access key on the first line,
then one line per signed header, terminated by a trailing newline:
<access_key>\n
<h1>: <value1>\n
<h2>: <value2>\nThe pseudo-header @request-target is rendered as <METHOD> <request-uri>
instead of a header lookup. signature = base64(HMAC(secret_key, signing_string)).
§Deviations from APISIX
- Consumer credentials use the field names
access_key/secret_key(featherbit’shmac-authconsumer index is keyed onaccess_key), whereas APISIX names themkey_id/secret_key. - A single
algorithmis accepted per node (defaulthmac-sha256) rather than APISIX’sallowed_algorithmslist; the client’s declared algorithm must match it. @request-target’s request URI is reconstructed from the parsed path plus a sortedkey=valuequery string (the original query byte order is not retained), so a client signing@request-targetmust canonicalise its query the same way.- Only the RFC 1123 (
Sun, 06 Nov 1994 08:49:37 GMT)Dateformat is parsed for clock-skew checks. - Request-body digest validation (
validate_request_body) is not implemented.
Structs§
- Hmac
Auth Plugin - Authenticates requests by verifying an HMAC signature over a canonical signing string.
- Hmac
Params 🔒 - Signature parameters extracted from the request.
Enums§
- Hmac
Algorithm 🔒 - Supported HMAC algorithms.
Constants§
- HDR_
ACCESS_ 🔒KEY - The X-HMAC-* header names (lowercased) used as the alternative to the
Authorization: Signature ...presentation. - HDR_
ALGORITHM 🔒 - HDR_
SIGNATURE 🔒 - HDR_
SIGNED_ 🔒HEADERS
Functions§
- now 🔒
- Current unix timestamp in seconds.
- parse_
http_ 🔒date - Parses an RFC 1123 HTTP date (
Sun, 06 Nov 1994 08:49:37 GMT) into a unix timestamp. ReturnsNoneon any malformed component.