Expand description
Requests from the Encore platform — cron jobs, the dashboard’s API calls —
and the x-encore-auth MAC it signs them with.
A cron job’s run also says why it runs (CRON_TRIGGER_HEADER) and
which run it is (CRON_EXECUTION_HEADER). The MAC covers neither.
The header is v2. followed by the unpadded standard base64 of the signing
key’s id (a big-endian u32) and
HMAC-SHA256(key, "v2\0" date "\0" method "\0" service "\0" path "\0" query):
the request’s Date header, its method, the service its x-encore-service
names (empty when absent), its path percent-decoded, as bytes, which need
not be UTF-8, and its query as sent, without the ? (empty when absent). A
request is accepted within MAX_SKEW of its date.
The path is signed decoded, as in v1, so a proxy re-encoding it on the way
does not break the MAC; %2F and / sign the same.
The v1 MAC, over the date and path alone, is not accepted: it does not cover the service a request names, so a captured request could be sent to another one. Neither covers the body.
Structs§
- Signed
- What a platform request’s MAC covers.
Enums§
Constants§
- AUTH_
HEADER - The header a platform request’s MAC is in.
- CALLER
- The caller a platform request is made as, in
x-encore-meta-caller, once verified. - CRON_
EXECUTION_ HEADER - The header the platform names a cron job’s run in: the same id each time it sends that run, so the job’s endpoint can use it as an idempotency key.
- CRON_
TRIGGER_ HEADER - The header the platform says why it runs a cron job in:
scheduled, ormanual. - MAX_
SKEW - How far a request’s date may be from the verifier’s clock.
Functions§
- is_
cron_ header - Whether
name, lowercase, is one of the headers the platform describes a cron job’s run with. Only the platform may send them: a gateway removes them from every request it has not verified as the platform’s. - sign
- The
x-encore-authvalue forreq, signed with the keykey_id. - verify
- Verifies that
header, a request’sx-encore-auth, signsreqwith one ofkeys, at mostMAX_SKEWfromnow.