kubernetes - Kubernetes Istio 配置与 Keycloak 用于 JWT 令牌验证
问题描述
我有以下架构:
一个 minikube 集群,我可以在其中使用 Keycloak 检索有效的 JWT 令牌进行登录。
我的下一步是使用 keycloak 配置 Istio,以便在访问我的微服务 API 之前验证令牌。
Keycloak 安装到集群中。这是我正在使用的 yaml:
apiVersion: "security.istio.io/v1beta1"
kind: "RequestAuthentication"
metadata:
name: "myapp-jwt"
namespace: istio-system
spec:
selector:
matchLabels:
istio: ingressgateway
jwtRules:
- issuer: "http://auth.xxxxxxxx.com/auth/realms/xxxxxxxx"
jwksUri: "http://keycloak.auth.svc.cluster.local/auth/realms/xxxxxxxx/protocol/openid-connect/certs"
我得到Jwks 没有匹配来自 Jwt 的 child 或 alg 的密钥
这些是我的另一个 yaml:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: myapp-gateway
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "myapp.xxxxxxxx.com"
- "auth.xxxxxxxx.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: myapp
spec:
hosts:
- "myapp.xxxxxxxx.com"
gateways:
- myapp-gateway
http:
- match:
- uri:
prefix: /actions
route:
- destination:
host: action-api-service.default.svc.cluster.local
port:
number: 3000
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: myapp-auth
namespace: auth
spec:
hosts:
- "auth.xxxxxxxx.com"
gateways:
- default/myapp-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: keycloak.auth.svc.cluster.local
port:
number: 8080
解决方案
推荐阅读
- postgresql - 根据时间戳范围展开(重复)记录(PostgreSQL)
- python - 在 Python C/C++ 扩展中实现装饰器,可以在 Python 中包装/装饰函数
- python - 识别类参数
- azure - 在 ADF 中连接自托管 IR 时出现问题
- php - 是否可以使用 Symfony 控制台实现并排表格布局?
- c++ - 第一次使用可变参数函数
- python - 如何在numpy数组列中查找数字序列
- node.js - 在共享的 Observable 上引发事件
- html - 如何在将鼠标悬停在其后的元素上时更改元素的 css?
- javascript - 我在 MySQL Hosting 中创建的数据库正在形成一个表,其中包含来自 JavaScript 中的 API 的空数据