如何在 AuthorizationPolicy deny 上自定义来自 Istio 的错误代码和响应主体?

How to customize the error code and response body from Istio on AuthorizationPolicy deny?

当请求被拒绝时,返回的回复是:

HTTP 403
RBAC: access denied

有没有办法自定义此错误以具有不同的状态代码和回复正文?

Istio 目前无法实现 API,但是 feature request for that on Github

还有 a workaround using an envoy filter 可以自定义该响应。

但是请注意,与 Istio API 和 Istio doc 相比,Envoy 过滤器是低级结构 说:

This feature must be used with care, as incorrect configurations could potentially destabilize the entire mesh.