Hi,
I want to integrate Tyk with Vault because I need to get secrets that will be injected as a header in the request, I managed to do it with middleware but I saw that there is a way to do it without it (tyk.io/docs/tyk-configuration-reference/kv-store/). But that part “For body transforms and URL rewrites, the prefixes are $ secret_vault., $ Secret_consul. And $ secret_conf.” it wasn’t very clear to me.
Example:
The configuration for the vault in the .config file looks like this:
"kv": {
"vault": {
"address": "http://host.docker.internal:8200",
"max_retries": 3,
"timeout": 30,
"token": "root",
"kv_version": 2
}
}
If I want to get the secrets via request I use the following address:
http://127.0.0.1:8200/v1/myengine/data/user1
engine name: myengine
path: user1
I’m trying to log the secret into the middleware like this:
log ($secret_vault.myengine.user1)
but I’m having the error:
time = “Apr 05 12:18:53” level = error msg = “Failed to run JS middleware” api_id = keyless api_name = “Tyk Test Keyless API” error = “ReferenceError: ‘$ secret_vault’ is not defined” mw = DynamicMiddleware org_id = default origin = 172.29.0.1 path = “/ keyless / get”
Can someone tell me how i can do this?
Marcos Oleiro