Authenticate Consumer using multiple JWTs from different sourcesv3.14+

Authenticate a Consumer by verifying a JWT from one of two possible sources, each backed by a different JWKS.

The plugin checks for a primary Authorization header first. If it doesn’t find the header, it falls back to a secondary Authorization2 header. The verified JWT’s sub claim is used to look up and authenticate the matching Kong Gateway Consumer.

This example contains the following nodes:

  1. The node HAS_AUTH1 checks whether a primary Authorization header is present.
  2. The node BRANCH_AUTH1 checks for an Authorization header. If the header exists, it extracts and verifies the JWT against JWKS1 and sets the Consumer; otherwise it checks for the secondary header.
  3. The nodes EXTRACT_AUTH1, VERIFY_AUTH1, BUILD_CONSUMER1, and SET_CONSUMER1 handle the primary JWT path.
  4. The node HAS_AUTH2 checks whether a secondary Authorization2 header is present.
  5. The node BRANCH_AUTH2 routes execution for the secondary JWT path.
  6. The nodes EXTRACT_AUTH2, VERIFY_AUTH2, BUILD_CONSUMER2, and SET_CONSUMER2 handle the secondary JWT path.

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!