A Kong plugin that extracts JWT claims and applies them as HTTP request headers.
requires Kong 1.0.x or greater
luarocks install kong-plugin-jwt-claims-to-headers
Edit kong.conf
. Add jwt-claims-to-headers
to the plugins
directive.
plugins = bundled,jwt-claims-to-headers
coming soon...
Add all JWT claims as headers using the default prefix X-JWT-Claim-
curl --request POST \
--url http://localhost:8001/services/my-service/plugins/ \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"name": "jwt-claims-to-headers",
"route_id": "71d39596-0f13-40ce-be00-cc21d2dc16f7",
"config": {
"header_prefix": "x-custom-prefix-"
}
}'
Add all JWT claims as headers using a custom prefix
--data '{
"name": "jwt-claims-to-headers",
"route_id": "71d39596-0f13-40ce-be00-cc21d2dc16f7",
"config": {
"header_prefix": "x-custom-prefix-"
}
}'
Add JWT iss
claim as header with custom name
--data '{
"name": "jwt-claims-to-headers",
"route_id": "7d04ba54-b019-4e38-b450-e66a2284f1aa",
"config": {
"claims_to_headers_table": {
"iss": "x-table-iss"
}
}
}'
The setup section describes the recommended installation method. The sub-sections below describe 1. manually installing the plugin, 2. validating the that the plugin was installed properly, and 3. uninstalling the plugin
# use lua package path or KONG LONG PACKAGE PATH
# e.g. lua_package_path = /</kong/plugins/jwt-claims-to-headers/?.lua;;
export KONG_LUA_PACKAGE_PATH=/kong/plugins/jwt-claims-to-headers/handler.lua?.lua;;
# edit the Kong configuration and modify the plugins directive to
plugins = bundled,jwt-claims-to-headers
To verify the plugin loaded on Kong start, edit kong.conf
and set log_level
to debug
.
# edit kong.conf and set
log_level = debug
Look for the following output:
[debug] Loading plugin jwt-clatims-to-headers
luarocks remove kong-plugin-jwt-claims-to-headers
If you would like to contribute to kong-plugin-jwt-claims-to-headers
, go here. We walk you through how to set up your developent environment.