-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Client IP Detection using XFF on ClientTrafficPolicy (#…
…2535) * feat: HTTPConnectionManager settings for XFF headers on ClientTrafficPolicy Signed-off-by: David Alger <davidmalger@gmail.com> * Remove useRemoteAddress configuration and rename section to originalIpDetection Signed-off-by: David Alger <davidmalger@gmail.com> * Add example curl request demonstrating request headers Signed-off-by: David Alger <davidmalger@gmail.com> * Implement support for original ip detection extensions Signed-off-by: David Alger <davidmalger@gmail.com> * Rename to clientIP Signed-off-by: David Alger <davidmalger@gmail.com> * Update tests Signed-off-by: David Alger <davidmalger@gmail.com> * Update docs Signed-off-by: David Alger <davidmalger@gmail.com> * Refactor xff / custom_header implementation Signed-off-by: David Alger <davidmalger@gmail.com> * Update tests Signed-off-by: David Alger <davidmalger@gmail.com> * Strip out customHeader support for now Signed-off-by: David Alger <davidmalger@gmail.com> * Make optional Signed-off-by: David Alger <davidmalger@gmail.com> * Cleanup Signed-off-by: David Alger <davidmalger@gmail.com> --------- Signed-off-by: David Alger <davidmalger@gmail.com>
- Loading branch information
1 parent
ca4657c
commit e3994ec
Showing
17 changed files
with
513 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
internal/gatewayapi/testdata/clienttrafficpolicy-client-ip-detection.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
clientTrafficPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: ClientTrafficPolicy | ||
metadata: | ||
namespace: envoy-gateway | ||
name: target-gateway-1 | ||
spec: | ||
clientIPDetection: | ||
xForwardedFor: | ||
numTrustedHops: 2 | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http-1 | ||
protocol: HTTP | ||
port: 8081 | ||
allowedRoutes: | ||
namespaces: | ||
from: Same |
98 changes: 98 additions & 0 deletions
98
internal/gatewayapi/testdata/clienttrafficpolicy-client-ip-detection.out.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
clientTrafficPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: ClientTrafficPolicy | ||
metadata: | ||
creationTimestamp: null | ||
name: target-gateway-1 | ||
namespace: envoy-gateway | ||
spec: | ||
clientIPDetection: | ||
xForwardedFor: | ||
numTrustedHops: 2 | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
status: | ||
conditions: | ||
- lastTransitionTime: null | ||
message: ClientTrafficPolicy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
creationTimestamp: null | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- allowedRoutes: | ||
namespaces: | ||
from: Same | ||
name: http-1 | ||
port: 8081 | ||
protocol: HTTP | ||
status: | ||
listeners: | ||
- attachedRoutes: 0 | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Sending translated listener configuration to the data plane | ||
reason: Programmed | ||
status: "True" | ||
type: Programmed | ||
- lastTransitionTime: null | ||
message: Listener has been successfully translated | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
- lastTransitionTime: null | ||
message: Listener references have been resolved | ||
reason: ResolvedRefs | ||
status: "True" | ||
type: ResolvedRefs | ||
name: http-1 | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
- group: gateway.networking.k8s.io | ||
kind: GRPCRoute | ||
infraIR: | ||
envoy-gateway/gateway-1: | ||
proxy: | ||
listeners: | ||
- address: null | ||
name: envoy-gateway/gateway-1/http-1 | ||
ports: | ||
- containerPort: 8081 | ||
name: http-1 | ||
protocol: HTTP | ||
servicePort: 8081 | ||
metadata: | ||
labels: | ||
gateway.envoyproxy.io/owning-gateway-name: gateway-1 | ||
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway | ||
name: envoy-gateway/gateway-1 | ||
xdsIR: | ||
envoy-gateway/gateway-1: | ||
accessLog: | ||
text: | ||
- path: /dev/stdout | ||
http: | ||
- address: 0.0.0.0 | ||
clientIPDetection: | ||
xForwardedFor: | ||
numTrustedHops: 2 | ||
hostnames: | ||
- '*' | ||
isHTTP2: false | ||
name: envoy-gateway/gateway-1/http-1 | ||
path: | ||
escapedSlashesAction: UnescapeAndRedirect | ||
mergeSlashes: true | ||
port: 8081 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
internal/xds/translator/testdata/in/xds-ir/client-ip-detection.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
http: | ||
- name: "first-listener" | ||
address: "0.0.0.0" | ||
port: 8081 | ||
hostnames: | ||
- "*" | ||
routes: | ||
- name: "first-route" | ||
hostname: "*" | ||
destination: | ||
name: "first-route-dest" | ||
settings: | ||
- endpoints: | ||
- host: "1.1.1.1" | ||
port: 8081 | ||
clientIPDetection: | ||
xForwardedFor: | ||
numTrustedHops: 2 |
Oops, something went wrong.