forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support to extract from different identifier on
JWT
(envo…
…yproxy#2206) * feat: introduce FromHeaders, FromCookies, and FromParams field to JWT Signed-off-by: Ardika Bagus <me@ardikabs.com> * test: add test for JWT custom extractor Signed-off-by: Ardika Bagus <me@ardikabs.com> * chore: trigger generate and manifest generation Signed-off-by: Ardika Bagus <me@ardikabs.com> * chore: add comment for JWTFromHeader attributes Signed-off-by: Ardika Bagus <me@ardikabs.com> * chore: rename field to extractFrom Signed-off-by: Ardika Bagus <me@ardikabs.com> * chore: exclude Params and Headers attribute prefer use case driven development which we have no needs for having different JWT extraction from either Params and Headers the default which is Authorization HTTP Header or access_token query parameters. Signed-off-by: Ardika Bagus <me@ardikabs.com> * docs: add doc string for JWTExtractor.Cookies if specified Signed-off-by: Ardika Bagus <me@ardikabs.com> --------- Signed-off-by: Ardika Bagus <me@ardikabs.com>
- Loading branch information
Showing
13 changed files
with
703 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
internal/gatewayapi/testdata/securitypolicy-with-jwt-with-custom-extractor.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-2 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
grpcRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1alpha2 | ||
kind: GRPCRoute | ||
metadata: | ||
namespace: default | ||
name: grpcroute-1 | ||
spec: | ||
parentRefs: | ||
- namespace: envoy-gateway | ||
name: gateway-1 | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
namespace: default | ||
name: httproute-1 | ||
spec: | ||
hostnames: | ||
- gateway.envoyproxy.io | ||
parentRefs: | ||
- namespace: envoy-gateway | ||
name: gateway-2 | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- path: | ||
value: "/" | ||
backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
securityPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: SecurityPolicy | ||
metadata: | ||
namespace: envoy-gateway | ||
name: policy-for-gateway | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
jwt: | ||
providers: | ||
- name: example1 | ||
issuer: https://one.example.com | ||
audiences: | ||
- one.foo.com | ||
remoteJWKS: | ||
uri: https://one.example.com/jwt/public-key/jwks.json | ||
claimToHeaders: | ||
- header: one-route-example-key | ||
claim: claim1 | ||
- name: example2 | ||
issuer: https://two.example.com | ||
audiences: | ||
- two.foo.com | ||
remoteJWKS: | ||
uri: https://two.example.com/jwt/public-key/jwks.json | ||
claimToHeaders: | ||
- header: two-route-example-key | ||
claim: claim2 | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: SecurityPolicy | ||
metadata: | ||
namespace: default | ||
name: policy-for-route | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: httproute-1 | ||
namespace: default | ||
jwt: | ||
providers: | ||
- name: example3 | ||
issuer: https://three.example.com | ||
audiences: | ||
- three.foo.com | ||
remoteJWKS: | ||
uri: https://three.example.com/jwt/public-key/jwks.json | ||
claimToHeaders: | ||
- header: three-route-example-key | ||
claim: claim3 | ||
extractFrom: | ||
cookies: | ||
- session_access_token |
Oops, something went wrong.