oathkeeper icon indicating copy to clipboard operation
oathkeeper copied to clipboard

[Feature] Access rule's `upstream.url` to support Go templates

Open rrmistry opened this issue 1 year ago • 0 comments

Preflight checklist

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

rrmistry avatar Jan 15 '25 22:01 rrmistry