Kraken Plugin - JWT Header Rewriter
1 Plugin Configuration
Name | Desciption | Default |
---|---|---|
name | Name of plugin | "" |
headers | List of key value pair headers to be set | null |
url | URL to send request to | "" |
2 Example Krakend Config
{
"version": 2,
"timeout": "3000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "confluent-rest-proxy-test",
"port": 8080,
"plugin": {
"pattern": ".so",
"folder": "./plugins/"
},
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true
}
},
"endpoints": [
{
"endpoint": "/",
"headers_to_pass": ["Authorization"],
"method": "GET",
"backend": [
{
"host": ["IGNORE"],
"url_pattern": "/",
"extra_config": {
"github.com/devopsfaith/krakend/transport/http/client/executor": {
"name": "confluent-rest-proxy",
"headers": {
"TENANT": "name"
},
"url": "https://jsonplaceholder.typicode.com/todos/1"
}
}
}
]
}
]
}
3 Develop
Getting Started:
- Clone repository.
- From project root run
make dev
. - Send test request to krakend
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" http://localhost:8080 -v
.
3.1 Makefile
make build
Builds confluent-rest-proxy.go for production and outputs in to the ./build directory.
make dev
does the following:
- Start docker containers specified in docker-compose.yml.
- Builds confluent-rest-proxy.go and outputs binary to ./krakend/plugins so it can be injected by the krakend container.
- Restarts krakend container.
- Tails krakend log.
make dev-build
does the following:
- Builds confluent-rest-proxy.go and outputs binary to ./krakend/plugins so it can be injected by the krakend container.
- Restarts krakend container.
- Tails krakend log.
make dev-stop
Stops all containers, same as docker-compose down
3.2 Test HTTP endpoint
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" http://localhost:8080 -v