Kong’s router runs before authentication, so it can’t directly route traffic based on who is making a request.
This guide shows you how to solve that using two plugins working together in the access phase:
-
OpenID Connect validates the bearer token and extracts a claim value (such as
client_id) onto a virtual credential. -
Datakit reads that credential and maps its value to a
host:portstring, setting it as the backend target for that specific request.
All callers share one Route and one Service, and the backend is decided dynamically after authentication.
This guide routes directly to a host:port backend, which bypasses Upstream entities, load balancing, health checks, and retries.
Use it when each backend is a fixed address and you don’t need a pool.
If you need load balancing or health checks, use Upstream entities instead.
Note: The OpenID Connect plugin has a higher static priority than Datakit, so it always runs first in the
accessphase. No explicit plugin ordering configuration is required.