Skip to content

Commit 8e0a0ea

Browse files
authored
fix ext-auth api: remove listener level fields (#11119)
Signed-off-by: Yuval Kohavi <[email protected]>
1 parent 954d4ca commit 8e0a0ea

26 files changed

+558
-757
lines changed

api/applyconfiguration/api/v1alpha1/extauthpolicy.go

Lines changed: 13 additions & 54 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: 2 additions & 11 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: 4 additions & 23 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: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ type ExtProcPolicy struct {
1313
// ProcessingMode defines how the filter should interact with the request/response streams
1414
// +optional
1515
ProcessingMode *ProcessingMode `json:"processingMode,omitempty"`
16-
17-
// FailureModeAllow defines the behavior of the filter when the external processing fails.
18-
// Defaults to false.
19-
// +optional
20-
FailureModeAllow *bool `json:"failureModeAllow,omitempty"`
2116
}
2217

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

api/v1alpha1/traffic_policy_types.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -184,48 +184,14 @@ type ExtAuthPolicy struct {
184184
// +optional
185185
Enablement ExtAuthEnabled `json:"enablement,omitempty"`
186186

187-
// FailureModeAllow determines the behavior on authorization service errors.
188-
// When true, requests will be allowed even if the authorization service fails or returns HTTP 5xx errors.
189-
// When unset, the default behavior is false.
190-
// +optional
191-
FailureModeAllow *bool `json:"failureModeAllow,omitempty"`
192-
193187
// WithRequestBody allows the request body to be buffered and sent to the authorization service.
194188
// Warning buffering has implications for streaming and therefore performance.
195189
// +optional
196190
WithRequestBody *BufferSettings `json:"withRequestBody,omitempty"`
197191

198-
// ClearRouteCache allows the authorization service to affect routing decisions.
199-
// When unset, the default behavior is false.
200-
// +optional
201-
ClearRouteCache *bool `json:"clearRouteCache,omitempty"`
202-
203-
// MetadataContextNamespaces specifies metadata namespaces to pass to the authorization service.
204-
// Default to allowing jwt info if processing for jwt is configured.
205-
// +optional
206-
// +listType=set
207-
// +kubebuilder:default={"jwt"}
208-
MetadataContextNamespaces []string `json:"metadataContextNamespaces,omitempty"`
209-
210-
// IncludePeerCertificate determines if the client's X.509 certificate should be sent to the authorization service.
211-
// When true, the certificate will be included if available.
212-
// When unset, the default behavior is false.
213-
// +optional
214-
IncludePeerCertificate *bool `json:"includePeerCertificate,omitempty"`
215-
216-
// IncludeTLSSession determines if TLS session details should be sent to the authorization service.
217-
// When true, the SNI name from TLSClientHello will be included if available.
218-
// When unset, the default behavior is false.
219-
// +optional
220-
IncludeTLSSession *bool `json:"includeTLSSession,omitempty"`
221-
222-
// EmitFilterStateStats determines if per-stream stats should be emitted for access logging.
223-
// When true and using Envoy gRPC, emits latency, bytes sent/received, and upstream info.
224-
// When true and not using Envoy gRPC, emits only latency.
225-
// Stats are only added if a check request is made to the ext_authz service.
226-
// When unset, the default behavior is false.
192+
// Additional context for the authorization service.
227193
// +optional
228-
EmitFilterStateStats *bool `json:"emitFilterStateStats,omitempty"`
194+
ContextExtensions map[string]string `json:"contextExtensions,omitempty"`
229195
}
230196

231197
// BufferSettings configures how the request body should be buffered.

api/v1alpha1/zz_generated.deepcopy.go

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

install/helm/kgateway-crds/templates/gateway.kgateway.dev_trafficpolicies.yaml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ spec:
275275
type: object
276276
extAuth:
277277
properties:
278-
clearRouteCache:
279-
type: boolean
280-
emitFilterStateStats:
281-
type: boolean
278+
contextExtensions:
279+
additionalProperties:
280+
type: string
281+
type: object
282282
enablement:
283283
enum:
284284
- DisableAll
@@ -290,19 +290,6 @@ spec:
290290
type: string
291291
type: object
292292
x-kubernetes-map-type: atomic
293-
failureModeAllow:
294-
type: boolean
295-
includePeerCertificate:
296-
type: boolean
297-
includeTLSSession:
298-
type: boolean
299-
metadataContextNamespaces:
300-
default:
301-
- jwt
302-
items:
303-
type: string
304-
type: array
305-
x-kubernetes-list-type: set
306293
withRequestBody:
307294
properties:
308295
allowPartialMessage:
@@ -330,8 +317,6 @@ spec:
330317
type: string
331318
type: object
332319
x-kubernetes-map-type: atomic
333-
failureModeAllow:
334-
type: boolean
335320
processingMode:
336321
properties:
337322
requestBodyMode:

internal/kgateway/extensions2/plugin/plugin.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package extensionsplug
22

33
import (
44
"context"
5+
"encoding/json"
56

67
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
78
envoy_config_endpoint_v3 "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
@@ -105,6 +106,19 @@ type (
105106
ProcessPolicyStatus func(ctx context.Context, gkString string, polReport PolicyReport)
106107
)
107108

109+
// marshal json for krt debugging
110+
func (p PolicyReport) MarshalJSON() ([]byte, error) {
111+
m := map[string]map[string][]error{}
112+
for key, pol := range p {
113+
objErrMap := map[string][]error{}
114+
for objKey, errs := range pol {
115+
objErrMap[objKey.ResourceName()] = errs
116+
}
117+
m[key.ID()] = objErrMap
118+
}
119+
return json.Marshal(m)
120+
}
121+
108122
func (p PolicyPlugin) AttachmentPoints() AttachmentPoints {
109123
var ret AttachmentPoints
110124
if p.ProcessBackend != nil {

internal/kgateway/extensions2/plugins/routepolicy/ai_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type AIPolicyIR struct {
3838
}
3939

4040
func (p *trafficPolicyPluginGwPass) processAITrafficPolicy(
41-
configMap ir.TypedFilterConfigMap,
41+
configMap *ir.TypedFilterConfigMap,
4242
inIr *AIPolicyIR,
4343
) error {
4444
if inIr.Transformation != nil {

internal/kgateway/extensions2/plugins/routepolicy/ai_policy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestProcessAITrafficPolicy(t *testing.T) {
4646
// Execute
4747
err := preProcessAITrafficPolicy(aiConfig, aiIR)
4848
require.NoError(t, err)
49-
err = plugin.processAITrafficPolicy(typedFilterConfig, aiIR)
49+
err = plugin.processAITrafficPolicy(&typedFilterConfig, aiIR)
5050
require.NoError(t, err)
5151

5252
// Verify streaming header was added
@@ -85,7 +85,7 @@ func TestProcessAITrafficPolicy(t *testing.T) {
8585
err := preProcessAITrafficPolicy(aiConfig, aiIR)
8686
require.NoError(t, err)
8787

88-
err = plugin.processAITrafficPolicy(typedFilterConfig, aiIR)
88+
err = plugin.processAITrafficPolicy(&typedFilterConfig, aiIR)
8989
require.NoError(t, err)
9090

9191
// Verify
@@ -124,7 +124,7 @@ func TestProcessAITrafficPolicy(t *testing.T) {
124124
err := preProcessAITrafficPolicy(aiConfig, aiIR)
125125
require.NoError(t, err)
126126

127-
err = plugin.processAITrafficPolicy(typedFilterConfig, aiIR)
127+
err = plugin.processAITrafficPolicy(&typedFilterConfig, aiIR)
128128
require.NoError(t, err)
129129

130130
// Verify
@@ -177,7 +177,7 @@ func TestProcessAITrafficPolicy(t *testing.T) {
177177
err := preProcessAITrafficPolicy(aiConfig, aiIR)
178178
require.NoError(t, err)
179179

180-
err = plugin.processAITrafficPolicy(typedFilterConfig, aiIR)
180+
err = plugin.processAITrafficPolicy(&typedFilterConfig, aiIR)
181181
require.NoError(t, err)
182182

183183
// Verify

0 commit comments

Comments
 (0)