envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Support destination port range in config.rbac.Permission

Open lexh opened this issue 5 years ago • 2 comments

I am using config.rbac.Permission to configure RBAC for a dynamic forward proxy.

My proxy configuration needs to support allowing large port ranges.

Today, I can achieved this by combining thousands of Permission.destination_port rules using Permission.Set.or_rules, similar to this (modified) snippet from the config.rbac.RBAC docs.

  "product-viewer":
    permissions:
        - and_rules:
            rules:
              - header: { name: ":method", exact_match: "GET" }
              - url_path:
                  path: { prefix: "/products" }
              - or_rules:
                  rules:
                    - destination_port: 1000
                    - destination_port: 1001
                    # .
                    # ... a lot of lines
                    # .
                    - destination_port: 1999

This is functional but cumbersome.

It would be more ergonomic if Permission had a destination port range field, similar to what exists in config.listener.ListenerFilterChainMatchPredicate.

lexh avatar Apr 16 '21 17:04 lexh

+1 to this. This not only makes the config simpler but also has the potential to greatly improve the performance by using some highly efficient data structure and algorithm for the matching.

In the future we probably could/should expand this design to other fields like path/header/IP where we know some people puts hundreds and thousands values in these fields.

yangminzhu avatar Apr 20 '21 22:04 yangminzhu

I think it is reasonable, since rules are too complicated to write currently. I will try to improve it.

zhxie avatar Jul 14 '21 05:07 zhxie