Message Signatures
The Grafbase Gateway can sign subgraph HTTP requests following RFC 9421. Read more on configuring message signatures.
A key file should be provided in the config. This key file should be one of:
- A JSON file containing a JWK.
- A PEM file containing a PKCS#8 private key.
We'll choose which algorithm to use based on the key file provided, but a specific algoithm can be provided in the configuration.
The available algorithms are:
hmac-sha256ed25519ecdsa-p256-sha256ecdsa-p384-sha384
If the provided key & algorithm don't match the gateway will refuse to start.
The algorithm you use for singing can have an impact on the latency of your subgraph requests. The list above is in performance order, from most performant to least performant. We recommend testing your chosen algorithm & settings if this is a concern - a message signing span will be output in tracing that can be used to determine the impact of your settings.
The Grafbase Gateway allows you to control which parts of a subgrah request are used as input to message signing. There are several settings for this:
- The
headerskey can control which headers are included or excluded. It has two sub-keys:includeshould be a list of headers to include in the signature. If not present, all headers will be included.excludeshould be a list of headers to exclude from the signature. This setting takes precedence overinclude
- The
derived_componentskey allows you to control which "derived components" are included. This defaults to["request_target"]. The following options are available:methodthe HTTP method.target_urithe full URL of the requestauthoritythe hostname of the requests target URLschemethe scheme of the requests target URLrequest_targetthe request target of the request.paththe absolute path of the request URL
- The
signature_parameterskey is a list of additional signature parameters to include. It currently only has one setting:noncecan be provided to include a random nonce in every requests signature.
expirycan be set to a duration string. (e.g."30s"for 30 seconds). If provided, signatures will expire after this duration.
Here is an example of these settings: