这是我的请求身份验证,
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name:prod-authenticator
namespace: prod
spec:
selector:
matchLabels:
istio: ingressgateway
jwtRules:
- issuer: https://securetoken.google.com/<project-id>
jwksUri: https://www.googleapis.com/service_accounts/v1/jwk/[email protected]
我的AuthorizationPolicy是这个,
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name:prod-authorized-api
namespace: prod
spec:
action: ALLOW
rules:
- from:
- source:
requestPrincipals: ["*"]
- to:
- operation:
paths: ["/user/ping"]
以下内容可帮助我排除没有有效令牌的运行状况路径(/ user / ping)。
我的虚拟服务是
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: user-svc-vs
namespace: prod
spec:
hosts:
- gateway.xxxx.com
gateways:
- istio-system/prod-gateway
http:
- match:
- uri:
prefix: /pop
route:
- destination:
host:user-svc.prod.svc.cluster.local
但是当检查时我可以看到只有健康api可以得到200休息,所有都可以得到404,当检查浏览器时我看到了
已从CORS策略阻止对来自源“ https:// <>”的“ https://”处的XMLHttpRequest的访问:对预检请求的响应未通过访问控制检查:无“ Access-Control-Allow-Origin”标头存在于请求的资源上。
在虚拟服务中,我尝试添加“ corsPolicy”,但没有任何效果。
示例虚拟服务尝试的示例是
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- route:
- destination:
host: ratings.prod.svc.cluster.local
subset: v1
corsPolicy:
allowOrigins:
- exact: https://example.com
allowMethods:
- POST
- GET
allowCredentials: false
allowHeaders:
- X-Foo-Bar
maxAge: "24h"
<<以上不是我们的例子,但是我已经复制了,但是我申请了当前的环境,但是还是没有运气!谁能帮上忙,整日为此苦苦挣扎:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句