-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:support configuring xff trusted cidrs
Signed-off-by: Rudrakh Panigrahi <[email protected]>
- Loading branch information
Showing
9 changed files
with
386 additions
and
41 deletions.
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
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
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
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
99 changes: 99 additions & 0 deletions
99
test/e2e/testdata/authorization-client-ip-trusted-cidrs.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,99 @@ | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: http-with-authorization-client-ip-1 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- matches: | ||
- path: | ||
type: Exact | ||
value: /protected1 | ||
backendRefs: | ||
- name: infra-backend-v1 | ||
port: 8080 | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: http-with-authorization-client-ip-2 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
parentRefs: | ||
- name: same-namespace | ||
rules: | ||
- matches: | ||
- path: | ||
type: Exact | ||
value: /protected2 | ||
backendRefs: | ||
- name: infra-backend-v1 | ||
port: 8080 | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: SecurityPolicy | ||
metadata: | ||
name: authorization-client-ip-1 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: http-with-authorization-client-ip-1 | ||
authorization: | ||
defaultAction: Allow | ||
rules: | ||
- name: "deny-location-1" # First matching rule is applied, so 192.168.1.0/24 will be denied | ||
action: Deny | ||
principal: | ||
clientCIDRs: | ||
- 192.168.1.0/24 | ||
- name: "allow-location-1" | ||
action: Allow | ||
principal: | ||
clientCIDRs: | ||
- 192.168.1.0/24 | ||
- 192.168.2.0/24 # First matching rule is applied, so 12.168.2.0/24 will be allowed | ||
- name: "deny-location-2" | ||
action: Allow | ||
principal: | ||
clientCIDRs: | ||
- 192.168.2.0/24 | ||
--- | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: SecurityPolicy | ||
metadata: | ||
name: authorization-client-ip-2 | ||
namespace: gateway-conformance-infra | ||
spec: | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: http-with-authorization-client-ip-2 | ||
authorization: | ||
defaultAction: Deny | ||
rules: | ||
- action: Allow | ||
principal: | ||
clientCIDRs: | ||
- 10.0.1.0/24 | ||
- 10.0.2.0/24 | ||
--- | ||
# This is a client traffic policy that enables client IP detection using the XFF header. | ||
# So, the client IP can be detected from the XFF header and used for authorization. | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: ClientTrafficPolicy | ||
metadata: | ||
name: enable-client-ip-detection | ||
namespace: gateway-conformance-infra | ||
spec: | ||
clientIPDetection: | ||
xForwardedFor: | ||
trustedCidrs: | ||
- "172.16.0.0/12" | ||
targetRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: same-namespace |
Oops, something went wrong.