Sign JWT with Consumer IDv3.14+

Sign an outgoing JWT in a request header using the authenticated Consumer’s ID as the subject. This example assumes a Consumer has already been authenticated before Datakit runs. This example contains the following nodes:

  1. The node GET_CONSUMER retrieves the currently authenticated Consumer object.
  2. The node BUILD_CLAIMS uses jq to extract the Consumer’s id and build a sub claim.
  3. The node SIGN_JWT signs a new JWT using an HMAC secret stored in Vault.
  4. The node BUILD_HEADER injects the signed token into an X-Consumer-JWT request header sent to the upstream service.

Note: Datakit has a priority of 810, which means it runs after rate limiting plugins (priority 900 and above). If you use Consumer-based rate limits, Datakit must run first so the Consumer is set before rate limiting executes. You can adjust this with dynamic plugin ordering.

Prerequisites

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!