lua之前的Envoy ext_authz过滤器

时间:2019-09-16 10:09:24

标签: envoyproxy

我正在尝试将ext_authz过滤器添加到我们的过滤器链中。问题是我们已经有了添加一些HTTP标头的LUA过滤器,并且我们的路由基于cluster_header。据我了解,它们两者不能一起工作。如果我将路由的cluster_header更改为确切的集群,则会调用ext_auth,否则LUA过滤器将起作用。除了在LUA内调用身份验证服务之外,有什么方法可以使它们协同工作?

配置如下:

filter_chains:
  - filters:
      - name: envoy.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
        stat_prefix: ingress_http
        route_config:
          name: local_route
          virtual_hosts:
            - name: main
              domains: ["*"]
              routes:
                - match:
                    prefix: "/"
                  route:
                    cluster_header: cluster
                    hash_policy:
                      header:
                        header_name: balancing-key
                  metadata:
                    filter_metadata:
                      envoy.lua:
                        default_cluster: some-cluster                
         http_filters:
           - name: envoy.ext_authz
             typed_config:
               "@type": type.googleapis.com/envoy.config.filter.http.ext_authz.v2.ExtAuthz
               grpc_service:
                 envoy_grpc:
                   cluster_name: ext-authz
           - name: envoy.lua
             typed_config:
               "@type": type.googleapis.com/envoy.config.filter.http.lua.v2.Lua
               inline_code: some-code

2 个答案:

答案 0 :(得分:0)

已解决。我刚刚在lua之后移动了ext_authz过滤器,它可以工作。

答案 1 :(得分:0)

github上的主题:https://github.com/envoyproxy/envoy/issues/8250

最后评论:

如果您查看“调用的解码头”行(在调用过滤器之后),我相信ext_authz在lua之前被调用。它什么也没做。该过滤器的encodeHeader实现中有一个if语句,如果没有路由或集群,它会跳过工作而不记录日志。因此,如果您在配置中包含cluster_header:cluster并使用lua过滤器设置集群头,则ext_authz将不会进行auth调用。