Header to metadata filter (#2436) (#3633)

Add support for extracting dynamic metadata from requests. This can then
be used as static metadata would be used (e.g.: for subset load balancer
metadata matches, logging, etc).

Risk Level: Low
Testing: unit-test
Docs Changes: Basic docs.
Release Notes: N/A

Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>

Mirrored from https://github.com/envoyproxy/envoy @ 827c0a548ab38d55debe00587ee27253786befad
pull/620/head
data-plane-api(CircleCI) 7 years ago
parent d3172dcf03
commit 4b04ff7611
  1. 1
      docs/BUILD
  2. 9
      envoy/config/filter/http/header_to_metadata/v2/BUILD
  3. 69
      envoy/config/filter/http/header_to_metadata/v2/header_to_metadata.proto
  4. 1
      envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto
  5. 1
      test/validate/BUILD
  6. 1
      test/validate/pgv_test.cc

@ -32,6 +32,7 @@ proto_library(
"//envoy/config/filter/http/ext_authz/v2alpha:ext_authz",
"//envoy/config/filter/http/fault/v2:fault",
"//envoy/config/filter/http/gzip/v2:gzip",
"//envoy/config/filter/http/header_to_metadata/v2:header_to_metadata",
"//envoy/config/filter/http/health_check/v2:health_check",
"//envoy/config/filter/http/ip_tagging/v2:ip_tagging",
"//envoy/config/filter/http/lua/v2:lua",

@ -0,0 +1,9 @@
load("//bazel:api_build_system.bzl", "api_proto_library")
licenses(["notice"]) # Apache 2
api_proto_library(
name = "header_to_metadata",
srcs = ["header_to_metadata.proto"],
deps = [],
)

@ -0,0 +1,69 @@
syntax = "proto3";
package envoy.config.filter.http.header_to_metadata.v2;
option go_package = "v2";
import "validate/validate.proto";
// [#protodoc-title: Header-To-Metadata Filter]
//
// The configuration for transforming headers into metadata. This is useful
// for matching load balancer subsets, logging, etc.
//
// Header to Metadata :ref:`configuration overview <config_http_filters_header_to_metadata>`.
message Config {
enum ValueType {
STRING = 0;
NUMBER = 1;
}
message KeyValuePair {
// The namespace if this is empty, the filter's namespace will be used.
string metadata_namespace = 1;
// The key to use within the namespace.
string key = 2 [(validate.rules).string.min_bytes = 1];
// The value to pair with the given key.
//
// When used for a `on_header_present` case, if value is non-empty it'll be used
// instead of the header value. If both are empty, no metadata is added.
//
// When used for a `on_header_missing` case, a non-empty value must be provided
// otherwise no metadata is added.
string value = 3;
// The value's type defaults to string.
ValueType type = 4;
}
// A Rule defines what metadata to apply when a header is present or missing.
message Rule {
// The header that triggers this rule required.
string header = 1 [(validate.rules).string.min_bytes = 1];
// If the header is present, apply this metadata KeyValuePair.
//
// If the value in the KeyValuePair is non-empty, it'll be used instead
// of the header value.
KeyValuePair on_header_present = 2;
// If the header is not present, apply this metadata KeyValuePair.
//
// The value in the KeyValuePair must be set, since it'll be used in lieu
// of the missing header value.
KeyValuePair on_header_missing = 3;
// Whether or not to remove the header after a rule is applied.
//
// This prevents headers from leaking.
bool remove = 4;
}
// The list of rules to apply to requests.
repeated Rule request_rules = 1;
// The list of rules to apply to responses.
repeated Rule response_rules = 2;
}

@ -298,6 +298,7 @@ message HttpFilter {
// * :ref:`envoy.grpc_json_transcoder <config_http_filters_grpc_json_transcoder>`
// * :ref:`envoy.grpc_web <config_http_filters_grpc_web>`
// * :ref:`envoy.health_check <config_http_filters_health_check>`
// * :ref:`envoy.header_to_metadata <config_http_filters_header_to_metadata>`
// * :ref:`envoy.ip_tagging <config_http_filters_ip_tagging>`
// * :ref:`envoy.lua <config_http_filters_lua>`
// * :ref:`envoy.rate_limit <config_http_filters_rate_limit>`

@ -18,6 +18,7 @@ api_cc_test(
"//envoy/config/filter/http/buffer/v2:buffer",
"//envoy/config/filter/http/fault/v2:fault",
"//envoy/config/filter/http/gzip/v2:gzip",
"//envoy/config/filter/http/header_to_metadata/v2:header_to_metadata",
"//envoy/config/filter/http/health_check/v2:health_check",
"//envoy/config/filter/http/ip_tagging/v2:ip_tagging",
"//envoy/config/filter/http/lua/v2:lua",

@ -15,6 +15,7 @@
#include "envoy/config/filter/http/fault/v2/fault.pb.validate.h"
#include "envoy/config/filter/http/gzip/v2/gzip.pb.validate.h"
#include "envoy/config/filter/http/health_check/v2/health_check.pb.validate.h"
#include "envoy/config/filter/http/header_to_metadata/v2/header_to_metadata.pb.validate.h"
#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.validate.h"
#include "envoy/config/filter/http/lua/v2/lua.pb.validate.h"
#include "envoy/config/filter/http/router/v2/router.pb.validate.h"

Loading…
Cancel
Save