Documentation
¶
Overview ¶
Package haproxyprobe is the probe the operator sends through HAProxy to tell whether a route runs the engine's SPOE filter (0002 §6.4): a GET with Header carrying a random nonce and a MAC of the nonce, the host and the path under the bundle's probe key. The path is one the route serves: PathSuffix under a Prefix path, so the probe reaches no real page of the app when the filter isn't there. The SPOE adapter checks the MAC and answers with another MAC under the key, which the route's HAProxy rules return with Status: only an engine that has the key, behind a route that runs the filter, can answer.
Where the proxy discards the engine's answer (Envoy's ext_proc in observability mode, a Detect-mode route through Istio), the engine keeps a Receipt of each probe it verified instead, and reports its recent ones to the operator (#475): another MAC under the key, which the operator expects for the probe's nonce, host and URI, and which neither the request nor an answer shows.
The response leg (#595) proves that a route's responses reach the engine too: the same probe, its URI marked with LegParam (under the MAC), which the engine lets through to the app instead of answering, and answers (or keeps a receipt of) in its response phase, with MACs of their own purpose.
Index ¶
- Constants
- func Check(key []byte, uri, host, header string) (answer string, ok bool)
- func ExpectedReceipt(key []byte, nonce, host, uri string) string
- func ExpectedResponseReceipt(key []byte, nonce, host, uri string) string
- func IsResponseURI(uri string) bool
- func NewNonce() (string, error)
- func PrefixPath(prefix, nonce string) string
- func Receipt(key []byte, uri, host, header string) (receipt string, ok bool)
- func Request(key []byte, nonce, host, uri string) string
- func ResponseLeg(key []byte, uri, host, header string) (answer, receipt string, ok bool)
- func ResponseURI(uri string) string
- func ValidReceipt(r string) bool
- func Verify(key []byte, nonce, host, uri, answer string) bool
- func VerifyResponse(key []byte, nonce, host, uri, answer string) bool
- type Receipts
Constants ¶
const ( // PathSuffix is the probe's path under a Prefix path, before the // nonce: /.well-known/inkwall-probe/<nonce> for the prefix "/". PathSuffix = ".well-known/inkwall-probe/" // Header carries the request's nonce and MAC ("<nonce>.<mac>"), and the // answer's MAC. Header = "X-Inkwall-Probe" // Status is HAProxy's answer to a probe the engine answered. Status = 299 // KeySize is the size of a probe key. KeySize = 32 // ReceiptSize is the length of a receipt: 32 hex digits, an // HMAC-SHA256 cut to 128 bits. ReceiptSize = 32 // MaxReceipts bounds the receipts an engine keeps, and reports: the // newest. MaxReceipts = 16 // ReceiptAge is how long an engine keeps a receipt. ReceiptAge = time.Minute // LegParam is the query parameter that marks a probe's response leg // (LegParam=ResponseLeg, last in the query): the engine lets it // through, and answers its response. LegParam = "inkwall-probe-leg" // ResponseLegValue is LegParam's value on the response leg. ResponseLegValue = "response" )
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check is the engine's side: for a request to uri (path and query) with the Host host and the given Header value, it returns the answer to send back, and whether the request is a probe made with key.
func ExpectedReceipt ¶ added in v0.6.0
ExpectedReceipt is the operator's side: the receipt of the probe with nonce to host and uri; "" without a key.
func ExpectedResponseReceipt ¶ added in v0.6.0
ExpectedResponseReceipt is the operator's side: the receipt of the response leg with nonce to host and uri; "" without a key.
func IsResponseURI ¶ added in v0.6.0
IsResponseURI reports whether uri is a response leg's (ResponseURI).
func PrefixPath ¶
PrefixPath is the probe's path under the Prefix path prefix.
func Receipt ¶ added in v0.6.0
Receipt is the engine's side where its answer is discarded: for a request as Check takes it, the receipt to keep, and whether the request is a probe made with key.
func ResponseLeg ¶ added in v0.6.0
ResponseLeg is the engine's side of the response leg: for a request as Check takes it, whether it is a response-leg probe made with key, and the answer to give in the response phase (where the proxy waits for it) or the receipt to keep there (where the proxy discards answers).
func ResponseURI ¶ added in v0.6.0
ResponseURI is the response leg's URI for the request leg's uri.
func ValidReceipt ¶ added in v0.6.0
ValidReceipt reports whether r has a receipt's form: ReceiptSize lowercase hex digits.
func Verify ¶
Verify is the operator's side: whether answer is the engine's answer to the probe with nonce to host and uri.
func VerifyResponse ¶ added in v0.6.0
VerifyResponse is the operator's side: whether answer is the engine's answer to the response leg with nonce to host and uri, given in its response phase.
Types ¶
type Receipts ¶ added in v0.6.0
type Receipts struct {
// Now is the clock; nil: time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Receipts are the receipts an engine keeps: at most MaxReceipts, the newest, none older than ReceiptAge, each once. The zero value is ready; a nil one keeps none.