How to implement istio authorization using oauth2 and keycloak

The redirection issue solved by updating authorization policy

apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: example-auth-policy
  namespace: istio-system
spec:
  action: CUSTOM
  provider:
    name: "oauth2-proxy"
  rules:
  - to:
    - operation:       
        paths: ["/app"]
        notPaths: ["/oauth2/*"]
  selector:
    matchLabels:
      app: istio-ingressgateway
  • Added istio-system namespace instead of workload namespace (it was default in my case)
  • Forgot to add matchLabels.