首页 > 解决方案 > Spring Boot、Minikube、Istio 和 Keycloak:“无效参数:redirect_uri”

问题描述

我有一个在 Minikube 中运行的应用程序,可以按预期与入口网关一起使用。调用 Spring Boot 应用程序,显示视图并通过链接调用受保护的资源。呼叫被转发到 Keycloak 并通过登录掩码进行授权,并按预期显示受保护的资源。

使用 Istio,重定向失败并显示消息:“无效参数:redirect_uri”。

我的 Istio 网关配置

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  namespace: istio-system
  name: istio-bomc-app-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

我的虚拟服务配置

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: istio-bomc-app-hrm-virtualservice
  namespace: bomc-app
spec:
  hosts:
  - "*"
  gateways:
  - istio-bomc-app-gateway.istio-system.svc.cluster.local
  http:
  - match:
    - uri:              
       prefix: /bomc-hrm
    route:
    - destination:
        host: bomc-hrm-service.bomc-app.svc.cluster.local
        port:
          number: 80

单击受保护的链接后,我在浏览器中得到以下 URI:

http://192.168.99.100:31380/auth/realms/bomc-hrm-realm/protocol/openid-connect/auth?response_type=code&client_id=bomc-hrm-app&redirect_uri=http%3A%2F%2F192.168.99.100% 2Fbomc-hrm%2Fui%2Fcustomer%2Fcustomers&state=4739ab56-a8f3-4f78-bd29-c05e7ea7cdbe&login=true&scope=openid

我看到redirect_uri=http%3A%2F%2F192.168.99.100%2F不完整。缺少端口 31380。

Istio VirtualService 需要如何配置?

标签: spring-bootkeycloakminikubeistio

解决方案


你有没有将以下命令签入谷歌云也许你会有使用它的线索

kubectl 描述

检查 Kube


推荐阅读