Skip to content

Commit

Permalink
[1.17]: Early Header Mutation (#10295)
Browse files Browse the repository at this point in the history
Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Nathan Fudenberg <[email protected]>
Co-authored-by: David Jumani <[email protected]>
  • Loading branch information
4 people authored Nov 8, 2024
1 parent 4877338 commit cf84b4a
Show file tree
Hide file tree
Showing 26 changed files with 1,630 additions and 391 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SOURCES := $(shell find . -name "*.go" | grep -v test.go)
# for more information, see https://github.com/solo-io/gloo/pull/9633
# and
# https://soloio.slab.com/posts/extended-http-methods-design-doc-40j7pjeu
ENVOY_GLOO_IMAGE ?= quay.io/solo-io/envoy-gloo:1.30.6-patch3
ENVOY_GLOO_IMAGE ?= quay.io/solo-io/envoy-gloo:1.30.6-patch5
LDFLAGS := "-X github.com/solo-io/gloo/pkg/version.Version=$(VERSION)"
GCFLAGS ?=

Expand Down
22 changes: 22 additions & 0 deletions changelog/v1.17.16/early-header-manipulation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/gloo/issues/9604
description: >-
Added support for early header manipulation on Gateways.
This feature allows headers to be manipulated before significant processing
and routing decisions.
It affords the ability to add or remove headers that affect request processing
and can be used to implement override headers.
This can be configured by setting the
`gateway.spec.httpGateway.options.httpConnectionManagerSettings.earlyHeaderMutation` field.
The headersToAdd field will add key-value pair headers to the request if not already
present or overwrite them unless append is set to true.
The headersToRemove field removes the specified headers and is processed after
the headers have been added.
- type: DEPENDENCY_BUMP
dependencyOwner: solo-io
dependencyRepo: envoy-gloo
dependencyTag: 1.30.6-patch5
description: >
Bumped the Envoy version to 1.30.6-patch5
Needed the Early Header Manipulation extensions enabled.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/static/content/osa_provided.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Name|Version|License
[inconshreveable/go-update](https://github.com/inconshreveable/go-update)|v0.0.0-20160112193335-8152e7eb6ccf|UNKNOWN
[jhump/protoreflect](https://github.com/jhump/protoreflect)|v1.15.3|Apache License 2.0
[kelseyhightower/envconfig](https://github.com/kelseyhightower/envconfig)|v1.4.0|MIT License
[go-httpbin/v2](https://github.com/mccutchen/go-httpbin)|v2.15.0|MIT License
[olekukonko/tablewriter](https://github.com/olekukonko/tablewriter)|v0.0.5|MIT License
[ginkgo/v2](https://github.com/onsi/ginkgo)|v2.17.0|MIT License
[onsi/gomega](https://github.com/onsi/gomega)|v1.30.0|MIT License
Expand Down
3 changes: 3 additions & 0 deletions docs/data/ProtoMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,9 @@ apis:
header_validation.options.gloo.solo.io.HeaderValidationSettings:
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/v1/options/header_validation/header_validation.proto.sk/#HeaderValidationSettings
package: header_validation.options.gloo.solo.io
headers.options.gloo.solo.io.EarlyHeaderManipulation:
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/v1/options/headers/headers.proto.sk/#EarlyHeaderManipulation
package: headers.options.gloo.solo.io
headers.options.gloo.solo.io.HeaderManipulation:
relativepath: reference/api/github.com/solo-io/gloo/projects/gloo/api/v1/options/headers/headers.proto.sk/#HeaderManipulation
package: headers.options.gloo.solo.io
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ require (
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
github.com/mccutchen/go-httpbin/v2 v2.15.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/mccutchen/go-httpbin/v2 v2.15.0 h1:3b2s8LMRR2aFd+8U+1Bx2kdgHNQ5ZQkQOiW8e52Jj9A=
github.com/mccutchen/go-httpbin/v2 v2.15.0/go.mod h1:GBy5I7XwZ4ZLhT3hcq39I4ikwN9x4QUt6EAxNiR8Jus=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down
87 changes: 87 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_Gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,35 @@ spec:
type: string
drainTimeout:
type: string
earlyHeaderManipulation:
properties:
headersToAdd:
items:
properties:
append:
nullable: true
type: boolean
header:
properties:
key:
type: string
value:
type: string
type: object
headerSecretRef:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
headersToRemove:
items:
type: string
type: array
type: object
enableTrailers:
nullable: true
type: boolean
Expand Down Expand Up @@ -1489,6 +1518,35 @@ spec:
type: string
drainTimeout:
type: string
earlyHeaderManipulation:
properties:
headersToAdd:
items:
properties:
append:
nullable: true
type: boolean
header:
properties:
key:
type: string
value:
type: string
type: object
headerSecretRef:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
headersToRemove:
items:
type: string
type: array
type: object
enableTrailers:
nullable: true
type: boolean
Expand Down Expand Up @@ -2791,6 +2849,35 @@ spec:
type: string
drainTimeout:
type: string
earlyHeaderManipulation:
properties:
headersToAdd:
items:
properties:
append:
nullable: true
type: boolean
header:
properties:
key:
type: string
value:
type: string
type: object
headerSecretRef:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
headersToRemove:
items:
type: string
type: array
type: object
enableTrailers:
nullable: true
type: boolean
Expand Down
29 changes: 29 additions & 0 deletions install/helm/gloo/crds/gateway.solo.io_v1_HttpListenerOption.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,35 @@ spec:
type: string
drainTimeout:
type: string
earlyHeaderManipulation:
properties:
headersToAdd:
items:
properties:
append:
nullable: true
type: boolean
header:
properties:
key:
type: string
value:
type: string
type: object
headerSecretRef:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
headersToRemove:
items:
type: string
type: array
type: object
enableTrailers:
nullable: true
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,35 @@ spec:
type: string
drainTimeout:
type: string
earlyHeaderManipulation:
properties:
headersToAdd:
items:
properties:
append:
nullable: true
type: boolean
header:
properties:
key:
type: string
value:
type: string
type: object
headerSecretRef:
properties:
name:
type: string
namespace:
type: string
type: object
type: object
type: array
headersToRemove:
items:
type: string
type: array
type: object
enableTrailers:
nullable: true
type: boolean
Expand Down
4 changes: 4 additions & 0 deletions projects/gloo/api/v1/options/hcm/hcm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "google/protobuf/any.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/options/tracing/tracing.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/options/protocol_upgrade/protocol_upgrade.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/options/protocol/protocol.proto";
import "github.com/solo-io/gloo/projects/gloo/api/v1/options/headers/headers.proto";


import "extproto/ext.proto";
Expand Down Expand Up @@ -240,4 +241,7 @@ message HttpConnectionManagerSettings {
InternalAddressConfig internal_address_config = 38;
// If true, configure Envoy to set the x-fowarded-port header to allow services to find Envoy's listener port.
google.protobuf.BoolValue append_x_forwarded_port = 40;

// Configuration for early header manipulation
headers.options.gloo.solo.io.EarlyHeaderManipulation early_header_manipulation = 41;
}
17 changes: 17 additions & 0 deletions projects/gloo/api/v1/options/headers/headers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ message HeaderManipulation {
repeated string response_headers_to_remove = 4;
}

// EarlyHeaderManipulation can be specified on Gateways to manipulate headers before significant processing
// has happened and routing decisions are made.
// Early header manipulation allows adding/removing headers that affect request processing
// and can be used to implement override headers.
// Note: The adding of headers happens before the removal of headers.
message EarlyHeaderManipulation {
// Specifies a list of HTTP headers that should be added to each request
// handled by this gateway. For more information, including
// details on header value syntax, see the
// [Envoy documentation](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers.html#) .
repeated .solo.io.envoy.api.v2.core.HeaderValueOption headers_to_add = 1;


// Specifies a list of HTTP headers that should be removed from each request
// handled by this gateway.
repeated string headers_to_remove = 2;
}

// Header name/value pair plus option to control append behavior.
message HeaderValueOption {
Expand Down
8 changes: 8 additions & 0 deletions projects/gloo/pkg/api/v1/options/hcm/hcm.pb.clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions projects/gloo/pkg/api/v1/options/hcm/hcm.pb.equal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cf84b4a

Please sign in to comment.