Skip to main content

Module gateway_stamp

Module gateway_stamp 

Source
Expand description

The stamp the container agents’ gateway forwarder puts on a model-gateway request, and what srv checks.

Where srv cannot see which container a request comes from (Docker Desktop: every container arrives from one address), a small forwarder on the agents network sees the container’s own address and says it to srv in three headers: the address, the time, and a proof. The proof is an HMAC of the address, the time, the request’s method and its target (path and query), made with a secret only srv and the forwarder have, so a stamp cannot be moved to another request, another address or another time. srv accepts a stamp only on the gateway’s own paths and for WINDOW_SECS.

Enums§

Refusal
Why a stamp is not accepted. Never shown to the caller beyond “refused”.

Constants§

HEADER_PEER
HEADER_PREFIX
Every header the forwarder sets starts with this; it removes any such header a client sent.
HEADER_PROOF
HEADER_TS
PATH_PREFIX
The model gateway’s path prefix: the only paths the forwarder forwards and a stamp is accepted on.
WINDOW_SECS
How long a stamp is good for after the time it names, in seconds.

Functions§

covered_target
The request target a stamp may cover: under PATH_PREFIX exactly as written, with nothing that could make a different path of it (an encoded byte, a backslash, an empty or dot segment).
proof
The proof for one request, as hex.
verify
The peer a stamp names, when it is good for this request now. The comparison of the proofs does not depend on where they differ.