Our setup includes a single instio-ingress installation with multiple gateways attached to it handling multiple domains, like:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: admin
namespace: default
labels:
app: admin
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: admin-tls
hosts:
- admin.example.com
- port:
number: 80
name: http
protocol: HTTP
tls:
httpsRedirect: true
hosts:
- admin.example.com
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: public
namespace: default
labels:
app: public
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: public-tls
hosts:
- public.example.com
- port:
number: 80
name: http
protocol: HTTP
tls:
httpsRedirect: true
hosts:
- public.example.com
We would like to use request authentication for most of our applications living on specific domains, like:
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: validate-jwt
namespace: istio-system
spec:
selector:
matchLabels:
istio: ingressgateway
jwtRules:
- issuer: "http://example.com/auth/realms/smaple"
jwksUri: "http://example.com/auth/realms/smaple/protocol/openid-connect/certs"
forwardOriginalToken: true
outputPayloadToHeader: 'x-jwt-payload'
The following auth policy enables access for both domains:
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: "allow-access"
namespace: istio-system
spec:
selector:
matchLabels:
istio: ingressgateway
action: ALLOW
rules:
- to:
- operation:
hosts: ["public.example.com", "admin.example.com"]
Everything is working like a charm, when:
- the auth header contains a well-formed JWT
- the auth header is not included within the request
The problem starts when the authorization header is included but contains a malformed payload, for e.g.:
curl 'https://public.example.com' \
-H 'authorization: Bearer null' \
--compressed
# Jwt is not in the form of Header.Payload.Signature with two dots and 3 sections
Unfortunately, I have no control over the UI which includes the invalid/malformed header.
How should I disable the JWT validation specifically for the domain public.example.com
?
Or should I try to remove the auth header with an EnvoyFilter
if the header contains Bearer: null
?
Btw, running on istio@1.17.1.