Istio 中的授权策略和请求认证有什么区别?

What are the differences between Authorization Policy and Request Authentication in Istio?

我正在测试 Istio(服务网格)授权和身份验证功能,并一直在做一些测试以在微服务环境中实现 JWT。而且文档不清楚对象种类 "AuthorizationPolicy" 和 "RequestAuthentication",

之间的区别

不确定您是否检查了那 2 个文档页面:

Authorization Policy and RequestAuthentication.

使用授权策略,您可以允许或拒绝请求,但您无法定义身份验证,因此将接受或不接受请求,但不考虑身份验证方法。

另一方面,RequestAuthentication 将定义用于验证请求的身份验证方法,但根本不会限制没有身份验证的请求,因此您需要一个链接到它的授权规则。

RequestAuthentication 文档中的这个短语对其进行了解释:

A request that does not contain any authentication credentials will be accepted but will not have any authenticated identity. To restrict access to authenticated requests only, this should be accompanied by an authorization rule.

因此,在您的授权策略中,您可以定义允许或拒绝请求的策略,并且您可以使用 RequestAuthentication 定义您的身份验证方法。

如果您想将其限制为经过身份验证的请求,则两者都需要。 基本上,最佳方法取决于您的用例。