header-to-metadata: add support for cookie to metadata (#12206)

header-to-metadata filter supports adding a header's value to a metadata key which is later used for subset load balancing.

This PR adds support for extracting a specific cookie value before it's added as metadata.

Signed-off-by: Radha Kumari <rkumari@slack-corp.com>

Mirrored from https://github.com/envoyproxy/envoy @ 4dfa844f56d637b6ec26f415f65035707cdf01c8
master-ci-test
data-plane-api(CircleCI) 5 years ago
parent b2cfc1e436
commit 073b4efe9c
  1. 28
      envoy/extensions/filters/http/header_to_metadata/v3/header_to_metadata.proto
  2. 24
      envoy/extensions/filters/http/header_to_metadata/v4alpha/header_to_metadata.proto

@ -86,29 +86,41 @@ message Config {
}
// A Rule defines what metadata to apply when a header is present or missing.
// [#next-free-field: 6]
message Rule {
option (udpa.annotations.versioning).previous_message_type =
"envoy.config.filter.http.header_to_metadata.v2.Config.Rule";
// The header that triggers this rule required.
string header = 1
[(validate.rules).string = {min_bytes: 1 well_known_regex: HTTP_HEADER_NAME strict: false}];
// If the header is present, apply this metadata KeyValuePair.
// Specifies that a match will be performed on the value of a header or a cookie.
//
// The header to be extracted.
string header = 1 [
(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false},
(udpa.annotations.field_migrate).oneof_promotion = "header_cookie_specifier"
];
// The cookie to be extracted.
string cookie = 5 [
(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false},
(udpa.annotations.field_migrate).oneof_promotion = "header_cookie_specifier"
];
// If the header or cookie is present, apply this metadata KeyValuePair.
//
// If the value in the KeyValuePair is non-empty, it'll be used instead
// of the header value.
// of the header or cookie value.
KeyValuePair on_header_present = 2;
// If the header is not present, apply this metadata KeyValuePair.
// If the header or cookie 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.
// of the missing header or cookie value.
KeyValuePair on_header_missing = 3;
// Whether or not to remove the header after a rule is applied.
//
// This prevents headers from leaking.
// This field is not supported in case of a cookie.
bool remove = 4;
}

@ -86,29 +86,39 @@ message Config {
}
// A Rule defines what metadata to apply when a header is present or missing.
// [#next-free-field: 6]
message Rule {
option (udpa.annotations.versioning).previous_message_type =
"envoy.extensions.filters.http.header_to_metadata.v3.Config.Rule";
// The header that triggers this rule required.
string header = 1
[(validate.rules).string = {min_bytes: 1 well_known_regex: HTTP_HEADER_NAME strict: false}];
oneof header_cookie_specifier {
// Specifies that a match will be performed on the value of a header or a cookie.
//
// The header to be extracted.
string header = 1
[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}];
// The cookie to be extracted.
string cookie = 5
[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}];
}
// If the header is present, apply this metadata KeyValuePair.
// If the header or cookie is present, apply this metadata KeyValuePair.
//
// If the value in the KeyValuePair is non-empty, it'll be used instead
// of the header value.
// of the header or cookie value.
KeyValuePair on_header_present = 2;
// If the header is not present, apply this metadata KeyValuePair.
// If the header or cookie 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.
// of the missing header or cookie value.
KeyValuePair on_header_missing = 3;
// Whether or not to remove the header after a rule is applied.
//
// This prevents headers from leaking.
// This field is not supported in case of a cookie.
bool remove = 4;
}

Loading…
Cancel
Save