gloo icon indicating copy to clipboard operation
gloo copied to clipboard

Support Nested Claims in JWTs claimToHeader setting

Open srenatus opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. Translating JWT claims to request headers only works for simple string claims, like role: foobar. It doesn't work for nested claims like

roles:
  tenant1: foobear
  tenant2: admin

Describe the solution you'd like There's some ways this could work, maybe by injecting the JSON as header value, like

roles: { "tenant1": "foobear", "tenant2": "admin"}

Describe alternatives you've considered Setting keepToken: true and having the upstream service deal with parsing the token claims.

Additional context This is similar, but not exactly the same as #2744 (RBAC with nested claims).

srenatus avatar Jun 04 '20 11:06 srenatus

note from @yuval-k , after cursory reading of filter code: underlying envoy filter uses a proto struct, the filter itself should already support nested claims. the claimToHeader functionality of the filter does not support nested claims, however

kdorosh avatar Aug 18 '20 21:08 kdorosh

The jwt filter supports the nested claims natively, and claimToHeader has been updated to support parsing nested claims at the top level.

Translating nested JWT claims now will translate the nested claim as follows:

{
  test: {
    company: "foo",
    field2: "bar" 
  },
 tenant2: admin
}

You can do:


claimsToHeaders:
  - claim: test
    header: x-company

Currently only supports direct claims in the header, not nested claim path parsing i.e.

            claimsToHeaders:
            - claim: test.company
              header: x-company

npolshakova avatar Apr 13 '21 13:04 npolshakova

This issue has been marked as stale because of no activity in the last 180 days. It will be closed in the next 180 days unless it is tagged "no stalebot" or other activity occurs.

github-actions[bot] avatar Dec 15 '23 19:12 github-actions[bot]

We have another prospect who is looking for this functionality. Currently, they have a workaround but it's fairly complex to do with the transformation filter that could become error prone.

willowmck avatar Apr 15 '24 18:04 willowmck