solo-io / gloo

The Feature-rich, Kubernetes-native, Next-Generation API Gateway Built on Envoy
https://docs.solo.io/
Apache License 2.0
4.09k stars 444 forks source link

Support Nested Claims in JWTs claimToHeader setting #3107

Open srenatus opened 4 years ago

srenatus commented 4 years ago

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).

kdorosh commented 4 years ago

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

npolshakova commented 3 years ago

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
github-actions[bot] commented 10 months ago

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.

willowmck commented 6 months ago

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.