oathkeeper
oathkeeper copied to clipboard
[Feature] Access rule's `upstream.url` to support Go templates
Preflight checklist
- [X] I could not find a solution in the existing issues, docs, nor discussions.
- [X] I agree to follow this project's Code of Conduct.
- [X] I have read and am following this repository's Contribution Guidelines.
- [X] I have joined the Ory Community Slack.
- [X] I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe your problem
Currently, if I set a Go template in the access rule's upstream.url property then it does not evaluate Go templates.
A simple example confirmed using:
// access-rules.json
[
{
"upstream": {
"url": "http://apisix-data-plane:80/{{ print .Subject }}",
},
// ... other properties
}
]
Results in the upstream receiving this url:
GET /%7B%7B%20print%20.Subject%20%7D%7D/my-app
When I expected the upstream to recieve:
GET /rohit/my-app
This is an elementary example, but the intention is to use more complex scenarios e.g.
http://my-apps-{{ printIndex .MatchContext.RegexpCaptureGroups 0 | title }}:80/api/{{ printIndex .MatchContext.RegexpCaptureGroups 1 | title }}/my-entity
Describe your ideal solution
The ideal solution would allow implementing Go templates in the Upstream URL so that we can have more dynamic paths and routing.
Workarounds or alternatives
So far, we are using APISIX as an API gateway with its proxy-rewrite plugin to implement a similar behavior. However, this adds an extra hop and is not an ideal long-term solution.
Version
oryd/oathkeeper:v0.40.8
Additional Context
No response