Kubernetes Istio 1.6授权策略没有正确的响应代码(如果来自交叉来源)
我们已经实现了这个安全过滤器,以便在JWT令牌到达后端服务之前对其进行预验证。它可以检查一些条件,作为您接受或拒绝请求的标准,这是很有帮助的 我们现在的问题是,当您将请求发送到另一个URL(我们已经在Kubernetes Istio 1.6授权策略没有正确的响应代码(如果来自交叉来源),kubernetes,istio,Kubernetes,Istio,我们已经实现了这个安全过滤器,以便在JWT令牌到达后端服务之前对其进行预验证。它可以检查一些条件,作为您接受或拒绝请求的标准,这是很有帮助的 我们现在的问题是,当您将请求发送到另一个URL(我们已经在VirtualService中配置了CORS策略)时,该策略拒绝了该请求,并且不会返回标题中的Access Control Allow Origin,它会在Chrome浏览器中触发CORS阻塞 以下是一些示例定义: 自定义入口网关的策略 apiVersion: security.istio.io/v
VirtualService
中配置了CORS策略)时,该策略拒绝了该请求,并且不会返回标题中的Access Control Allow Origin
,它会在Chrome浏览器中触发CORS阻塞
以下是一些示例定义:
自定义入口网关的策略
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: custom-ingress
namespace: istio-system
spec:
selector:
matchLabels:
gateway-name: custom-ingress
jwtRules:
- issuer: https://some-issuer.com/
jwksUri: https://some-issuer.com/.well-known/jwks.json
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: custom-ingress
namespace: istio-system
spec:
selector:
matchLabels:
gateway-name: custom-ingress
action: DENY
rules:
- from:
- source:
notRequestPrincipals: ["*"]
to:
- operation:
methods: ["POST"]
paths:
- /restricted/path/A
- /restricted/path/B
- /restricted/path/C
服务虚拟服务
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: my-service
spec:
hosts:
- some-host.com
gateways:
- istio-system/custom-gateway
http:
- name: my-service-route
match:
- uri:
exact: /restricted/path/A
rewrite:
uri: /A
route:
- destination:
host: my-service
subset: stable
port:
number: 8080
corsPolicy:
allowOrigins:
- prefix: https://some-origin.com
allowMethods:
- OPTIONS
- POST
- GET
- PUT
- PATCH
- DELETE
allowCredentials: false
allowHeaders:
- authorization
- content-type
- accept
- origin
- grpc-timeout
- keep-alive
- user-agent
- cache-control
- content-transfer-encoding
- x-accept-content-transfer-encoding
- x-accept-response-streaming
- x-user-agent
- x-grpc-web
maxAge: "1h"
当Chrome浏览器请求:
Access Control Allow Origin
您认为我应该怎么做?如果我错了,请纠正我,但这不是按照您的配置工作吗?您在授权策略中拒绝POST方法,所以当POST从auth策略中获得403时,选项get、put、patch和delete应该起作用?如果您从身份验证策略中删除
方法:[“POST”]
,并且只保留路径,我认为应该可以工作。如果我错了,请纠正我,但这不是按照您的配置工作吗?您在授权策略中拒绝POST方法,所以当POST从auth策略中获得403时,选项get、put、patch和delete应该起作用?我假设如果您从身份验证策略中删除方法:[“POST”]
,并且只保留路径,那么它应该可以工作。