envoyproxy / envoyproxy/gateway
How to match JWT claims with a header using dynamically?
- Dominant language
- Go
- Stars
- 3k
- Forks
- 864
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 140
Description
I am working with envoygateway. And I am trying to authorize a request using the claims mentioned in the JWT token. https://gateway.envoyproxy.io/docs/tasks/security/jwt-claim-authorization/
The incoming request has a header called tenant-id.
And the claim can contain a list of values under a claim called tenants.
The request should be allowed only if the the header x-scope-org-id contains a value that is part of the tenant claim.
Currently I don't find a way to dynamically access the
```
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
name: authorization-jwt-claim
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: HTTPRoute
name: backend
jwt:
providers:
- name: example
issuer: https://foo.bar.com
remoteJWKS:
uri: https://raw.githubusercontent.com/envoyproxy/gateway/refs/heads/main/examples/kubernetes/jwt/jwks.json
authorization:
defaultAction: Deny
rules:
- name: "allow"
action: Allow
principal:
jwt:
provider: example
claims:
- name: tenants
values: ["ABC"]
- name: "allow"
action: Allow
principal:
jwt:
provider: example
claims:
- name: tenants
values: ["DEF"]
```
And in this way the security policy will explode.
What I am looking for is to achieve something like following than string literal.
```
- name: "allow"
action: Allow
principal:
jwt:
provider: example
claims:
- name: tenants
values: ["%REQ(tenant-id)%"] << Error: not working
```
So how can I evaluate a header and compare with a claim.
I am open to ideas.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.