我通过 kubernate 中的 Keycloak 使用 traefic 1.7 进行服务身份验证。(我已经有了 Bearer 令牌,只需要通过 Keycloak 验证它)
我的入口控制器如下所示:
---
apiVersion: v1
kind: ConfigMap
metadata:
name: traefik-conf
namespace: kube-system
data:
traefik.toml: |
# traefik.toml
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.my-api]
address = ":9999"
[entryPoints.my-api.auth.forward]
address = "https://keycloak-host/auth/realms/R-1/protocol/openid-connect/userinfo"
trustForwardHeader = true
[kubernetes]
namespaces = ["n1", "n2","n3","n4"]
[respondingTimeouts]
readTimeout = "120s"
writeTimeout = "5s"
idleTimeout = "360s"
问题是我在 Keycoak 中有不同组织的不同领域。在我拥有的请求标头中Org-Id
,我需要放置而不是 R-1:
address = "https://keycloak-host/auth/realms/R-${Org-Id}/protocol/openid-connect/userinfo"
有没有办法从请求中提取标头并将其放置到地址路径中?