How to deploy the x-custom-jwt plugin in Konnect
Konnect is a hybrid architecture based on a Control Plane (for managing the configuration) and on Data Planes (aka the proxy gateway, for managing the API traffic) offering isolation for better security and performance.
Deploying a custom plugin requires updating the Control Plane and Data Planes:
- The Control Plane is updated by receiving the schema.lua which holds the schema of its configuration and defines rules on it so that the user can only enter valid configuration values
- The Data Planes need to be updated with the new custom plugin logic that we have defined. We can do this either by creating a custom image in Docker with our code or creating a configmap in the Kubernetes cluster and pointing Kong to that configmap on startup
Prerequisite
Do a Git Clone of the repo:
Deploy the plugin schema in Konnect (Control Plane)
1. Login to Konnect
2. Select your Gateway Manager
3. Click on Plugins
4. Click on + New Plugin
5. Click on Custom Plugins
6. Click on Create Custom Plugin
7. Click on Select file and open the schema.lua
8. Click on Save
Deploy the plugin in Kong Gateway (Data Plane) | Docker
1. See Data plane installation for Konnect documentation and select Docker
2. Update your docker container configuration with:
Mount definition (($(pwd) refers to kong-plugin-x-custom-jwt directory)
Environmental variable:
Deploy the plugin in Kong Gateway (Data Plane) | Kubernetes
1. See Data plane installation for Konnect documentation and select Kubernetes
2. Create configMap
3. Add the following properties to the Helm values.yaml:
4. Execute the helm install:
How to test the plugin
In the rest of the document, we consider that the Kong Gateway is available at https://kong-gateway:8443. Please adapt this URL according to your environment.
Configuration of the Gateway Service, the Routes, and the plugins
1. Login to Konnect
2. Select the Gateway Manager
3. Create a Route to deliver the public JWKS (used by the backend API or jwt.io to verify the new JWT crafted by the plugin)
The Route has the following properties:
- name=x-custom-jwt-jwks
- path=/x-custom-jwt/jwks
- Click on Save
Add the Request Termination plugin to the x-custom-jwt-jwks Route with:
Add the CORS plugin to the x-custom-jwt-jwks Route with:
- config.origins=*
- Click on Save
4. Create an httpbin Gateway Service for testing the plugin
Add a Gateway Service with:
Add a Route to the Service with:
- name=basicAuth
- path=/basicAuth
- Click on Save
Add Basic Authentication plugin to the basicAuth Route (Leave default parameters)
Add x-custom-jwt plugin to the httpbin Service with:
5. Create a Consumer with:
Open the Consumer and Go on Credentials / Basic Authentication, click on a + New Basic Auth Credential and put:
- username=my-user
- password=My p@ssword!
- Click on Save