Hi KrakenD community,
I’m using KrakenD with Keycloak for JWT validation. Currently, I have one endpoint defined via Helm for a single realm, pointing to its jwk_url.
Now, I need to support multiple realms (around 7–8), each with its own JWKS URL, for example:
realm1.example.com/api/upload → http://sso.example.com/realms/realm1/protocol/openid-connect/certs
realm2.example.com/api/upload → http://sso.example.com/realms/realm2/protocol/openid-connect/certs
… up to 7–8 realms
I want a dynamic way for KrakenD to select the correct JWKS URL at runtime based on the request (e.g., using the Host header), without defining a separate endpoint for each realm.
Has anyone implemented a pattern or configuration for this? Are there plugins or best practices to handle multiple Keycloak realms efficiently in KrakenD?
Thanks for any guidance!
My idea is to:
Inspect the Host header (e.g., realm1.example.com, realm2.example.com)
Dynamically select the correct JWKS URL for validation
Validate the token against that realm’s keys before passing the request to the backend
Is it feasible to implement JWT validation dynamically with Lua in CE?