【问题标题】:istio exclude service from ext-authistio 从 ext-auth 中排除服务
【发布时间】:2020-08-17 10:22:44
【问题描述】:

大家好,我已经在 minikube 上设置了 istio,并在网关上设置了 envoy ext-auth 过滤器。我有两个微服务在不同的 pod 中运行,将虚拟服务 /auther 和 /appone 暴露给外界。我设置的 ext-auth 过滤器会将每个请求发送到 /auther/auth 进行身份验证,如果响应为 200,则让请求通过并到达它想要的其他服务。 问题是 istio 正在验证对所有端点的每一个请求,甚至是 /auther。我想排除发送到 /auther 以进行身份​​验证的请求(因为 auther 服务将自行处理身份验证)。但它不起作用。 所以这是我的 ext-auth 过滤器:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: authn-filter
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
    - applyTo: HTTP_FILTER
      match:
        context: GATEWAY
        listener:
          filterChain:
            filter:
              name: "envoy.http_connection_manager"
              subFilter:
                name: "envoy.router"
      patch:
        operation: INSERT_BEFORE
        value:
          name: envoy.ext_authz
          typed_config:
            "@type": "type.googleapis.com/envoy.config.filter.http.ext_authz.v2.ExtAuthz"
            http_service:
              server_uri:
                uri: http://auther.default.svc.cluster.local
                cluster: outbound|3000||auther.default.svc.cluster.local
                timeout: 1.5s
              path_prefix: /auther/auth?user=
              authorizationRequest:
                allowedHeaders:
                  patterns:
                    - exact: "cookie"
                    - exact: "authorization"
              authorizationResponse:
                allowedClientHeaders:
                  patterns:
                    - exact: "set-cookie"
                    - exact: "authorization"


这是我试图实现的异常过滤器:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: bypass-filter
  namespace: default
spec:
  configPatches:
    # The first patch adds the lua filter to the listener/http connection manager
    - applyTo: HTTP_ROUTE
      match:
        context: GATEWAY
        routeConfiguration:
          vhost:
            name: auther
            route:
              name: auther
      patch:
        operation: MERGE
        value:
          typed_per_filter_config:
            envoy.ext_authz:
              "@type": type.googleapis.com/envoy.config.filter.http.ext_authz.v2.ExtAuthzPerRoute
              disabled: true

第一个过滤器工作得很好。但是第二个将从身份验证 ext-filter 中排除 auther 服务的功能不起作用。

【问题讨论】:

    标签: authentication filter istio envoyproxy


    【解决方案1】:

    您已将@type 设置为envoy.config.filter.http.ext_authz.v2.ExtAuthzPerRoute,但正确的路径是envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute

    此外,路由名称必须与虚拟服务中的名称匹配。它必须作为authn-filter 部署到istio-system 命名空间。这个配置对我有用:

    apiVersion: networking.istio.io/v1alpha3
    kind: EnvoyFilter
    metadata:
      name: bypass-authn
      namespace: istio-system
    spec:
      workloadSelector:
        labels:
          istio: ingressgateway
      configPatches:
        - applyTo: HTTP_ROUTE
          match:
            routeConfiguration:
              vhost:
                route:
                  name: my-route #from virtual service http route name
          patch:
            operation: MERGE
            value:
              name: envoy.ext_authz_disabled
              typed_per_filter_config:
                envoy.ext_authz:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
                  disabled: true
    

    【讨论】:

    • 你使用的是哪个 istio 版本?
    • 我在 istio 1.6 和 1.7 中使用过这个
    • 我使用了你说的一些配置,我没有工作
    • 您是否还在 istio-system 命名空间中部署了部署和服务,或者只是网关和虚拟服务?
    • 部署、服务、网关和虚拟服务在我所有应用程序的同一个命名空间中(不是 istio-system)。
    猜你喜欢
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-17
    • 2021-12-01
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    相关资源
    最近更新 更多