You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/v1alpha1/clienttrafficpolicy_types.go
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -281,7 +281,8 @@ const (
281
281
282
282
// ClientIPDetectionSettings provides configuration for determining the original client IP address for requests.
283
283
//
284
-
// +kubebuilder:validation:XValidation:rule="!(has(self.xForwardedFor) && has(self.customHeader))",message="customHeader cannot be used in conjunction with xForwardedFor"
284
+
// Exactly one of XForwardedFor, CustomHeader, or DirectSourceIP must be set.
285
+
// +kubebuilder:validation:XValidation:rule="[has(self.xForwardedFor), has(self.customHeader), has(self.directSourceIP)].filter(x, x).size() == 1",message="exactly one of xForwardedFor, customHeader, or directSourceIP must be set"
285
286
typeClientIPDetectionSettingsstruct {
286
287
// XForwardedForSettings provides configuration for using X-Forwarded-For headers for determining the client IP address.
287
288
//
@@ -294,8 +295,25 @@ type ClientIPDetectionSettings struct {
Copy file name to clipboardExpand all lines: api/v1alpha1/securitypolicy_types.go
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ type SecurityPolicy struct {
37
37
38
38
// SecurityPolicySpec defines the desired state of SecurityPolicy.
39
39
//
40
-
// NOTE: SecurityPolicy can target Gateway, HTTPRoute, GRPCRoute, TCPRoute, and TLSRoute.
40
+
// NOTE: SecurityPolicy can target Gateway, ListenerSet, HTTPRoute, GRPCRoute, and TCPRoute, and TLSRoute.
41
41
// When a SecurityPolicy targets a TCPRoute or TLSRoute, only client-IP CIDR based authorization
42
42
// (Authorization rules that use Principal.ClientCIDRs) is applied. Other
43
43
// authentication/authorization features such as JWT, API Key, Basic Auth,
@@ -46,17 +46,20 @@ type SecurityPolicy struct {
46
46
//
47
47
// +kubebuilder:validation:XValidation:rule="(has(self.targetRef) && !has(self.targetRefs)) || (!has(self.targetRef) && has(self.targetRefs)) || (has(self.targetSelectors) && self.targetSelectors.size() > 0) ", message="either targetRef or targetRefs must be used"
48
48
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.group == 'gateway.networking.k8s.io' : true", message="this policy can only have a targetRef.group of gateway.networking.k8s.io"
49
-
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
49
+
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
50
50
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.group == 'gateway.networking.k8s.io') : true ", message="this policy can only have a targetRefs[*].group of gateway.networking.k8s.io"
51
-
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
51
+
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/TLSRoute"
52
+
// +kubebuilder:validation:XValidation:rule="!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute'])))", message="mergeType can only be used with xRoute targets"
52
53
// +kubebuilder:validation:XValidation:rule="(has(self.authorization) && has(self.authorization.rules) && self.authorization.rules.exists(r, has(r.principal) ? has(r.principal.jwt) : false)) ? has(self.jwt) : true", message="if authorization.rules.principal.jwt is used, jwt must be defined"
53
54
typeSecurityPolicySpecstruct {
54
55
PolicyTargetReferences`json:",inline"`
55
56
56
57
// MergeType determines how this configuration is merged with existing SecurityPolicy
57
58
// configurations targeting a parent resource. When set, this configuration will be merged
58
-
// into a parent SecurityPolicy (i.e. the one targeting a Gateway or Listener).
59
-
// This field cannot be set when targeting a parent resource (Gateway).
59
+
// into the closest parent SecurityPolicy in the route's attachment hierarchy (for
60
+
// example, one targeting a Gateway, Gateway listener, ListenerSet, or ListenerSet
61
+
// listener).
62
+
// Currently, this field can only be set when targeting xRoute resources.
60
63
// If unset, no merging occurs, and only the most specific configuration takes effect.
61
64
//
62
65
// +kubebuilder:validation:XValidation:rule="self != 'Replace'",message="Replace is not a valid MergeType for SecurityPolicy"
0 commit comments