Combining OIDC and JWT authentication #2425
Replies: 6 comments 17 replies
-
@sadovnikov are the service clients and browser clients reaching the same designation endpoint ? if not, you could split up intent (different path matches) into separate HTTPRoutes, and a different BackendTrafficPolicy config for each HTTPRoute |
Beta Was this translation helpful? Give feedback.
-
These two HTTPRoutes are equivalent, they both match the same requests sent to "reference-apps.platform-lab.internal.xxx.yyy/cbdp-k8s-sample-pr-195". So when the requests com in, they may be sent to one route or the other, depends on which HTTPRoute is the first one in the xDS route configuration, which is random. I suggest a configuration like this:
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: cbdp-k8s-sample-web-pr-195-jwt
namespace: reference-apps
spec:
hostnames:
- reference-apps.platform-lab.internal.xxx.yyy
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: default
namespace: envoy-gateway-system
rules:
- backendRefs:
- group: ""
kind: Service
name: cbdp-k8s-sample-web-pr-195
port: 80
weight: 1
matches:
- path:
type: PathPrefix
value: /cbdp-k8s-sample-pr-195/application-endpoint
- apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: cbdp-k8s-sample-web-pr-195-oidc
namespace: reference-apps
spec:
hostnames:
- reference-apps.platform-lab.internal.xxx.yyy
parentRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: default
namespace: envoy-gateway-system
rules:
- backendRefs:
- group: ""
kind: Service
name: cbdp-k8s-sample-web-pr-195
port: 80
weight: 1
matches:
- path:
type: PathPrefix
value: /cbdp-k8s-sample-pr-195/user-endpoint Or they can use different hostname such as "api.reference-apps.platform-lab.internal.xxx.yyy" and "www.reference-apps.platform-lab.internal.xxx.yyy"
I think we can put the jwt filter in front of the oauth2 filter, but I guess you wouldn't want OIDC for those requests that only need jwt. As I said, they serve different purposes. |
Beta Was this translation helpful? Give feedback.
-
@zhaohuabing, I understand your answer. Thank you! Most probably, now we'll go with using different hostnames. However, I think, the question of ordering and combining different authentication methods on the same "host/path" will be coming up from other users too |
Beta Was this translation helpful? Give feedback.
-
@sadovnikov Different authentication methods(Basic, JWT, OIDC, etc) can be combined in a Regarding the ordering, do you have any specific use cases that you need to change the order of the filters for different Route? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Not sure if this is the best place to ask but subject seems to be on point. We have OIDC provider configured as below: apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
name: foobar-public
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: foobar-public
# NOTE: when uncommented then shows: Jwt is not in the form of Header.Payload.Signature with two dots and 3 sections
# ^ after being successfully authenticated using OIDC
# jwt:
# providers:
# - name: jumpcloud
# remoteJWKS:
# uri: "https://oauth.id.jumpcloud.com/.well-known/jwks.json"
oidc:
provider:
issuer: "https://oauth.id.jumpcloud.com"
clientID: "FOOBAR"
clientSecret:
kind: Secret
name: "foobar-client-secret"
logoutPath: "/logout"
redirectURL: https://FOOBAR/oauth2/callback
scopes:
- openid
- email We can see that
but how we can reference value from Cookie / Envoy / OIDC? 🤔 |
Beta Was this translation helpful? Give feedback.
-
I'm testing OIDC authentication, which is planned for the
v1.0
release and, so far, have not discovered any problems with OIDC implementation itself. However, I'm failing to create aSecurityPolicy
or their combination to authorise requests using either JWT or OIDC.In our use case, the same URLs can be used
Currently, if OIDC authentication is configured, requests with valid JWT get redirected to the IDP.
Is there a way to configure the gateway to redirect to IDP only those requests that do not have a valid JWT token?
Beta Was this translation helpful? Give feedback.
All reactions