Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to .MatchContext.RegexpCaptureGroups doesn't render in access rules authenticator config #1141

Open
5 tasks done
sunnyyip opened this issue Dec 1, 2023 · 0 comments
Labels
bug Something is not working.

Comments

@sunnyyip
Copy link

sunnyyip commented Dec 1, 2023

Preflight checklist

Ory Network Project

https://naughty-tesla-4oqisau3a4.projects.oryapis.com

Describe the bug

I have an access rule aiming to enforce JWT audience to match the requested domain. However .MatchContext.RegexpCaptureGroups reference, defined in the audience field, didn’t render (cause of the error) and get printed out literally in the log.

{ "id": "protected_resources", "version": "v0.40.6", "match": { "url": "<http|https>://<.*>/<playground|query|anything/header>", "methods": [ "GET", "POST" ] }, "authenticators": [ { "handler": "jwt", "config": { "target_audience": [ "{{ printIndex .MatchContext.RegexpCaptureGroups 0 }}://{{ printIndex .MatchContext.RegexpCaptureGroups 1 }}" ] } } ],

Reproducing the bug

  1. include an url with regex match group
  2. reference the match group in JWT authenticator config - e.g. audience
  3. make a request to oathkeeper
  4. observe errors in logs due to .MatchContext.RegexpCaptureGroups being treated as string literally

Relevant log output

"reason": "id=\nrid=\nerror=The request could not be authorized\nreason=Token audience [https://my.domain.com] is not intended for target audience {{ printIndex .MatchContext.RegexpCaptureGroups 0 }}://{{ printIndex .MatchContext.RegexpCaptureGroups 1 }}

Relevant configuration

{
    "id": "protected_resources",
    "version": "v0.40.6",
    "match": {
      "url": "<http|https>://<.*>/<playground|query|anything/header>",
      "methods": [
        "GET",
        "POST"
      ]
    },
    "authenticators": [
      {
        "handler": "jwt",
        "config": {
          "target_audience": [
            "{{ printIndex .MatchContext.RegexpCaptureGroups 0 }}://{{ printIndex .MatchContext.RegexpCaptureGroups 1 }}"
          ]
        }
      }
    ],

Version

v0.40.6

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes with Helm

Additional Context

No response

@sunnyyip sunnyyip added the bug Something is not working. label Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant