A Kong plugin that enables an extra HTTP POST/GET request - jwt-reconcile-request
- before proxying to the original request.
In some cases, you may need to validate your requests using a separated HTTP service.
For every incoming request, you might forward the path
, host
, headers
and body
to your jwt-reconcile-request
. The body response might be injected into the original header request.
$ luarocks install kong-plugin-jwt-reconcile
Update the plugins
config to add jwt-reconcile
:
plugins = bundled,jwt-reconcile
- Request with some JWT;
jwt-reconcile
will sendjwt-reconcile-request
to some service;- The service will validate the JWT, perform some custom logic and return a JSON with
role
anduserId
properties; jwt-reconcile
will add therole
anduserId
to the original header:x-role
andx-user-id
;- The destination service doesn't need to validate the JWT, just rely on the headers
x-role
andx-user-id
.
You can add the plugin on top of an API by executing the following request on your Kong server:
$ curl -X POST http://kong:8001/apis/{api}/plugins \
--data "name=jwt-reconcile" \
--data "config.url=http://myservice:8080"
Parameter | default | description |
---|---|---|
config.url |
[required] | Service where the requests will be made. |
config.path |
/api/v1/auth/reconcile | Path on service where the requests will be made. |
config.method |
POST | Allowed values: POST and GET . |
config.connect_timeout |
5000 | Connection timeout (in ms) to the provided url. |
config.send_timeout |
10000 | Send timeout (in ms) to the provided url. |
config.read_timeout |
10000 | Read timeout (in ms) to the provided url. |
config.copy_headers |
true | Forward the request headers to jwt-reconcile-request headers. |
config.forward_path |
false | Forward the request path to jwt-reconcile-request body. |
config.forward_query |
false | Forward the request query to jwt-reconcile-request body. |
config.forward_headers |
false | Forward the request headers to jwt-reconcile-request body. |
config.forward_body |
false | Forward the request body to jwt-reconcile-request body. |
config.inject_body_response_into_header |
true | Inject jwt-reconcile-request response into the request header. Note: The response MUST BE a JSON and the property key will be dasherized (kebab-case). |
config.injected_header_prefix |
"" (empty) | Prefix to the injected headers. |
config.streamdown_injected_headers |
false | When this option is enabled, jwt-reconcile will add to the response header all headers added by jwt-reconcile and by the middle-service. |