Skip to content

Commit 493e9f0

Browse files
upgrade to latest dependencies (#622)
bumping knative.dev/eventing e804605...d5e9973: > d5e9973 feat: add complete request reply data plane (# 8699) > e8e8035 Add auth-proxy and enable on IntegrationSink (# 8708) > 941dafa Fix mt-broker-ingress auth to work with structured event too (# 8710) > 69e11e3 [Automated] Update eventing-eventing-integrations nightly (# 8711) bumping knative.dev/serving a87c794...93577e9: > 93577e9 Update net-contour nightly (# 16074) > dc7691c Update net-istio nightly (# 16072) > 917f5c1 Update net-gateway-api nightly (# 16071) Signed-off-by: Knative Automation <automation@knative.team>
1 parent af26c3c commit 493e9f0

File tree

10 files changed

+407
-74
lines changed

10 files changed

+407
-74
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ require (
1515
k8s.io/apimachinery v0.33.4
1616
k8s.io/client-go v0.33.4
1717
k8s.io/code-generator v0.33.4
18-
knative.dev/eventing v0.46.1-0.20250909143134-e804605aa34a
18+
knative.dev/eventing v0.46.1-0.20250910170819-d5e9973e559b
1919
knative.dev/hack v0.0.0-20250902153942-1499de21e119
2020
knative.dev/pkg v0.0.0-20250909010931-8c9c1d368e4b
21-
knative.dev/serving v0.46.1-0.20250909224032-a87c794330dc
21+
knative.dev/serving v0.46.1-0.20250910032334-93577e9cb30c
2222
)
2323

2424
require (

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,16 @@ k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUy
374374
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8=
375375
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
376376
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
377-
knative.dev/eventing v0.46.1-0.20250909143134-e804605aa34a h1:vxv0GGRvlYp7XbkInA41v/ccXkypkZmOKmszGK+pkUk=
378-
knative.dev/eventing v0.46.1-0.20250909143134-e804605aa34a/go.mod h1:3rkUNHlYs6U0bs6IhufoBgIzUnsJY+ExNNreAHtv2Dw=
377+
knative.dev/eventing v0.46.1-0.20250910170819-d5e9973e559b h1:u2n46/rTmab70HoKGaa/sRCeKXv9K4MTxspKQNrKnjc=
378+
knative.dev/eventing v0.46.1-0.20250910170819-d5e9973e559b/go.mod h1:NP1ypjTAP+eZTT1P/Xk8DAI+dkqkWatFP73IikS4BIo=
379379
knative.dev/hack v0.0.0-20250902153942-1499de21e119 h1:NbQvjnFK1tL489LN0qAybWy0E17Jpziwcv/XIHwfp6M=
380380
knative.dev/hack v0.0.0-20250902153942-1499de21e119/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY=
381381
knative.dev/networking v0.0.0-20250909015233-e3b68fc57bea h1:712x0cJVdyKELYhO9Asie79wD4AvW/6bmdqGAAB6QYQ=
382382
knative.dev/networking v0.0.0-20250909015233-e3b68fc57bea/go.mod h1:P8mxand4fkoIIucr7pVv4sVk3IpTGGCQpJbwKu8fhy4=
383383
knative.dev/pkg v0.0.0-20250909010931-8c9c1d368e4b h1:Gscoeovr8XvQffYg6l2d7V8M5FuaJg34Hjg8e9sg21Y=
384384
knative.dev/pkg v0.0.0-20250909010931-8c9c1d368e4b/go.mod h1:OLfYBCgDhdEpaC2TEixU3e7byMEQmke/MHP3xsR7Gmo=
385-
knative.dev/serving v0.46.1-0.20250909224032-a87c794330dc h1:jXlre/XEno0QIkCUeRA6xJVbXnxz+YZkXDmtvS51jCY=
386-
knative.dev/serving v0.46.1-0.20250909224032-a87c794330dc/go.mod h1:pERRORu4itdaYfKSoNx5mhP2IduUkEQIClBQ5eXWBig=
385+
knative.dev/serving v0.46.1-0.20250910032334-93577e9cb30c h1:HTvPrb9EclY4We6o6eDN3blELg/50XN8wVw20qBoODE=
386+
knative.dev/serving v0.46.1-0.20250910032334-93577e9cb30c/go.mod h1:pERRORu4itdaYfKSoNx5mhP2IduUkEQIClBQ5eXWBig=
387387
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
388388
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
389389
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=

vendor/knative.dev/eventing/pkg/apis/sinks/v1alpha1/integration_sink_lifecycle.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ const (
4343

4444
// Certificate related condition reasons
4545
IntegrationSinkCertificateNotReady string = "CertificateNotReady"
46+
47+
// IntegrationSinkTrustBundlePropagated is configured to indicate whether the
48+
// TLS trust bundle has been properly propagated.
49+
IntegrationSinkTrustBundlePropagated apis.ConditionType = "TrustBundlePropagated"
4650
)
4751

4852
var IntegrationSinkCondSet = apis.NewLivingConditionSet(
4953
IntegrationSinkConditionAddressable,
5054
IntegrationSinkConditionDeploymentReady,
5155
IntegrationSinkConditionEventPoliciesReady,
56+
IntegrationSinkTrustBundlePropagated,
5257
)
5358

5459
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
@@ -151,12 +156,26 @@ func (s *IntegrationSinkStatus) PropagateCertificateStatus(cs cmv1.CertificateSt
151156
return true
152157
}
153158

154-
func (s *IntegrationSinkStatus) SetAddress(address *duckv1.Addressable) {
155-
s.Address = address
156-
if address == nil || address.URL.IsEmpty() {
159+
func (s *IntegrationSinkStatus) SetAddresses(addresses ...duckv1.Addressable) {
160+
if len(addresses) == 0 || addresses[0].URL.IsEmpty() {
157161
IntegrationSinkCondSet.Manage(s).MarkFalse(IntegrationSinkConditionAddressable, "EmptyHostname", "hostname is the empty string")
158-
} else {
159-
IntegrationSinkCondSet.Manage(s).MarkTrue(IntegrationSinkConditionAddressable)
162+
return
163+
}
160164

165+
s.AddressStatus = duckv1.AddressStatus{
166+
Address: &addresses[0],
167+
Addresses: addresses,
161168
}
169+
IntegrationSinkCondSet.Manage(s).MarkTrue(IntegrationSinkConditionAddressable)
170+
}
171+
172+
// MarkFailedTrustBundlePropagation marks the IntegrationSink's SinkBindingTrustBundlePropagated condition to False with
173+
// the provided reason and message.
174+
func (s *IntegrationSinkStatus) MarkFailedTrustBundlePropagation(reason, message string) {
175+
IntegrationSinkCondSet.Manage(s).MarkFalse(IntegrationSinkTrustBundlePropagated, reason, message)
176+
}
177+
178+
// MarkTrustBundlePropagated marks the IntegrationSink's SinkBindingTrustBundlePropagated condition to True.
179+
func (s *IntegrationSinkStatus) MarkTrustBundlePropagated() {
180+
IntegrationSinkCondSet.Manage(s).MarkTrue(IntegrationSinkTrustBundlePropagated)
162181
}

vendor/knative.dev/eventing/pkg/auth/event_policy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ func resolveSubjectsFromReference(resolver *resolver.AuthenticatableResolver, re
219219
// SubjectAndFiltersPass checks if the given sub is contained in the list of allowedSubs
220220
// or if it matches a prefix pattern in subs (e.g. system:serviceaccounts:my-ns:*), as
221221
// well as if the event passes any filters associated with the subjects for an event policy
222-
func SubjectAndFiltersPass(ctx context.Context, sub string, allowedSubsWithFilters []subjectsWithFilters, event *cloudevents.Event, logger *zap.SugaredLogger) bool {
222+
func SubjectAndFiltersPass(ctx context.Context, sub string, allowedSubsWithFilters []SubjectsWithFilters, event *cloudevents.Event, logger *zap.SugaredLogger) bool {
223223
if event == nil {
224224
return false
225225
}
226226

227227
for _, swf := range allowedSubsWithFilters {
228-
for _, s := range swf.subjects {
228+
for _, s := range swf.Subjects {
229229
if strings.EqualFold(s, sub) || (strings.HasSuffix(s, "*") && strings.HasPrefix(sub, strings.TrimSuffix(s, "*"))) {
230-
return subscriptionsapi.CreateSubscriptionsAPIFilters(logger.Desugar(), swf.filters).Filter(ctx, *event) != eventfilter.FailFilter
230+
return subscriptionsapi.CreateSubscriptionsAPIFilters(logger.Desugar(), swf.Filters).Filter(ctx, *event) != eventfilter.FailFilter
231231
}
232232
}
233233
}

vendor/knative.dev/eventing/pkg/auth/verifier.go

Lines changed: 68 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package auth
1818

1919
import (
20-
"bytes"
2120
"context"
2221
"encoding/json"
2322
"fmt"
@@ -32,6 +31,7 @@ import (
3231
"go.opentelemetry.io/otel"
3332
corev1listers "k8s.io/client-go/listers/core/v1"
3433
"knative.dev/eventing/pkg/eventingtls"
34+
"knative.dev/eventing/pkg/utils"
3535
"knative.dev/pkg/configmap"
3636
"knative.dev/pkg/network"
3737
"knative.dev/pkg/observability/tracing"
@@ -136,6 +136,30 @@ func (v *Verifier) VerifyRequestFromSubject(ctx context.Context, features featur
136136
return nil
137137
}
138138

139+
// VerifyRequestFromSubjectsWithFilters verifies AuthN and AuthZ in the request.
140+
// In the AuthZ part it checks if the request comes from the given allowedSubject.
141+
// On verification errors, it sets the responses HTTP status and returns an error.
142+
// This method is similar to VerifyRequestFromSubject() except that
143+
// VerifyRequestFromSubjectsWithFilters() allows to check based on a list of
144+
// subjects with filters.
145+
func (v *Verifier) VerifyRequestFromSubjectsWithFilters(ctx context.Context, features feature.Flags, requiredOIDCAudience *string, allowedSubjectsWithFilters []SubjectsWithFilters, resourceNamespace string, req *http.Request, resp http.ResponseWriter) error {
146+
if !features.IsOIDCAuthentication() {
147+
return nil
148+
}
149+
150+
idToken, err := v.verifyAuthN(ctx, requiredOIDCAudience, req, resp)
151+
if err != nil {
152+
return fmt.Errorf("authentication of request could not be verified: %w", err)
153+
}
154+
155+
err = v.verifyAuthZBySubjectsWithFilters(ctx, features, idToken, resourceNamespace, allowedSubjectsWithFilters, req, resp)
156+
if err != nil {
157+
return fmt.Errorf("authorization of request could not be verified: %w", err)
158+
}
159+
160+
return nil
161+
}
162+
139163
// verifyAuthN verifies if the incoming request contains a correct JWT token
140164
func (v *Verifier) verifyAuthN(ctx context.Context, audience *string, req *http.Request, resp http.ResponseWriter) (*IDToken, error) {
141165
token := GetJWTFromHeader(req.Header)
@@ -160,8 +184,20 @@ func (v *Verifier) verifyAuthN(ctx context.Context, audience *string, req *http.
160184

161185
// verifyAuthZ verifies if the given idToken is allowed by the resources eventPolicyStatus
162186
func (v *Verifier) verifyAuthZ(ctx context.Context, features feature.Flags, idToken *IDToken, resourceNamespace string, policyRefs []duckv1.AppliedEventPolicyRef, req *http.Request, resp http.ResponseWriter) error {
163-
if len(policyRefs) > 0 {
164-
req, err := copyRequest(req)
187+
subjectsWithFiltersFromApplyingPolicies, err := SubjectWithFiltersFromPolicyRef(v.eventPolicyLister, resourceNamespace, policyRefs)
188+
if err != nil {
189+
resp.WriteHeader(http.StatusInternalServerError)
190+
return fmt.Errorf("could not get subjects with filters from policy: %w", err)
191+
}
192+
193+
return v.verifyAuthZBySubjectsWithFilters(ctx, features, idToken, resourceNamespace, subjectsWithFiltersFromApplyingPolicies, req, resp)
194+
}
195+
196+
// verifyAuthZBySubjectsWithFilters verifies if the given idToken is allowed by the resources eventPolicyStatus
197+
// it does the same as verifyAuthZ but taking a subjectWithFilters slice instead
198+
func (v *Verifier) verifyAuthZBySubjectsWithFilters(ctx context.Context, features feature.Flags, idToken *IDToken, resourceNamespace string, subjectsWithFiltersFromApplyingPolicies []SubjectsWithFilters, req *http.Request, resp http.ResponseWriter) error {
199+
if len(subjectsWithFiltersFromApplyingPolicies) > 0 {
200+
req, err := utils.CopyRequest(req)
165201
if err != nil {
166202
resp.WriteHeader(http.StatusInternalServerError)
167203
return fmt.Errorf("failed to copy request body: %w", err)
@@ -176,38 +212,26 @@ func (v *Verifier) verifyAuthZ(ctx context.Context, features feature.Flags, idTo
176212
return fmt.Errorf("failed to decode event from request: %w", err)
177213
}
178214

179-
subjectsWithFiltersFromApplyingPolicies := []subjectsWithFilters{}
180-
for _, p := range policyRefs {
181-
policy, err := v.eventPolicyLister.EventPolicies(resourceNamespace).Get(p.Name)
182-
if err != nil {
183-
resp.WriteHeader(http.StatusInternalServerError)
184-
return fmt.Errorf("failed to get eventPolicy: %w", err)
185-
}
186-
187-
subjectsWithFiltersFromApplyingPolicies = append(subjectsWithFiltersFromApplyingPolicies, subjectsWithFilters{subjects: policy.Status.From, filters: policy.Spec.Filters})
188-
}
189-
190215
if !SubjectAndFiltersPass(ctx, idToken.Subject, subjectsWithFiltersFromApplyingPolicies, event, v.logger) {
191216
resp.WriteHeader(http.StatusForbidden)
192217
return fmt.Errorf("token is from subject %q, but only %#v are part of applying event policies", idToken.Subject, subjectsWithFiltersFromApplyingPolicies)
193218
}
194219

195220
return nil
196-
} else {
197-
if features.IsAuthorizationDefaultModeDenyAll() {
198-
resp.WriteHeader(http.StatusForbidden)
199-
return fmt.Errorf("no event policies apply for resource and %s is set to %s", feature.AuthorizationDefaultMode, feature.AuthorizationDenyAll)
200-
201-
} else if features.IsAuthorizationDefaultModeSameNamespace() {
202-
if !strings.HasPrefix(idToken.Subject, fmt.Sprintf("%s:%s:", kubernetesServiceAccountPrefix, resourceNamespace)) {
203-
resp.WriteHeader(http.StatusForbidden)
204-
return fmt.Errorf("no policies apply for resource. %s is set to %s, but token is from subject %q, which is not part of %q namespace", feature.AuthorizationDefaultMode, feature.AuthorizationDenyAll, idToken.Subject, resourceNamespace)
205-
}
221+
}
206222

207-
return nil
223+
if features.IsAuthorizationDefaultModeDenyAll() {
224+
resp.WriteHeader(http.StatusForbidden)
225+
return fmt.Errorf("no event policies apply for resource and %s is set to %s", feature.AuthorizationDefaultMode, feature.AuthorizationDenyAll)
226+
} else if features.IsAuthorizationDefaultModeSameNamespace() {
227+
if !strings.HasPrefix(idToken.Subject, fmt.Sprintf("%s:%s:", kubernetesServiceAccountPrefix, resourceNamespace)) {
228+
resp.WriteHeader(http.StatusForbidden)
229+
return fmt.Errorf("no policies apply for resource. %s is set to %s, but token is from subject %q, which is not part of %q namespace", feature.AuthorizationDefaultMode, feature.AuthorizationDenyAll, idToken.Subject, resourceNamespace)
208230
}
209-
// else: allow all
231+
232+
return nil
210233
}
234+
// else: allow all
211235

212236
return nil
213237
}
@@ -335,35 +359,6 @@ func (v *Verifier) getKubernetesOIDCDiscovery(features feature.Flags, client *ht
335359
return openIdConfig, nil
336360
}
337361

338-
// copyRequest makes a copy of the http request which can be consumed as needed, leaving the original request
339-
// able to be consumed as well.
340-
func copyRequest(req *http.Request) (*http.Request, error) {
341-
// check if we actually need to copy the body, otherwise we can return the original request
342-
if req.Body == nil || req.Body == http.NoBody {
343-
return req, nil
344-
}
345-
346-
var buf bytes.Buffer
347-
if _, err := buf.ReadFrom(req.Body); err != nil {
348-
return nil, fmt.Errorf("failed to read request body while copying it: %w", err)
349-
}
350-
351-
if err := req.Body.Close(); err != nil {
352-
return nil, fmt.Errorf("failed to close original request body ready while copying request: %w", err)
353-
}
354-
355-
// set the original request body to be readable again
356-
req.Body = io.NopCloser(&buf)
357-
358-
// return a new request with a readable body and same headers as the original
359-
// we don't need to set any other fields as cloudevents only uses the headers
360-
// and body to construct the Message/Event.
361-
return &http.Request{
362-
Header: req.Header,
363-
Body: io.NopCloser(bytes.NewReader(buf.Bytes())),
364-
}, nil
365-
}
366-
367362
type openIDMetadata struct {
368363
Issuer string `json:"issuer"`
369364
JWKSURI string `json:"jwks_uri"`
@@ -372,7 +367,22 @@ type openIDMetadata struct {
372367
SigningAlgs []string `json:"id_token_signing_alg_values_supported"`
373368
}
374369

375-
type subjectsWithFilters struct {
376-
filters []eventingv1.SubscriptionsAPIFilter
377-
subjects []string
370+
func SubjectWithFiltersFromPolicyRef(eventPolicyLister listerseventingv1alpha1.EventPolicyLister, resourceNamespace string, policyRefs []duckv1.AppliedEventPolicyRef) ([]SubjectsWithFilters, error) {
371+
subjectsWithFiltersFromApplyingPolicies := make([]SubjectsWithFilters, 0, len(policyRefs))
372+
373+
for _, p := range policyRefs {
374+
policy, err := eventPolicyLister.EventPolicies(resourceNamespace).Get(p.Name)
375+
if err != nil {
376+
return nil, fmt.Errorf("failed to get eventPolicy: %w", err)
377+
}
378+
379+
subjectsWithFiltersFromApplyingPolicies = append(subjectsWithFiltersFromApplyingPolicies, SubjectsWithFilters{Subjects: policy.Status.From, Filters: policy.Spec.Filters})
380+
}
381+
382+
return subjectsWithFiltersFromApplyingPolicies, nil
383+
}
384+
385+
type SubjectsWithFilters struct {
386+
Filters []eventingv1.SubscriptionsAPIFilter `json:"filters,omitempty"`
387+
Subjects []string `json:"subjects,omitempty"`
378388
}

vendor/knative.dev/eventing/pkg/eventingtls/eventingtls.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
corev1listers "k8s.io/client-go/listers/core/v1"
3737
"k8s.io/client-go/tools/cache"
3838
"knative.dev/pkg/apis"
39+
duckv1 "knative.dev/pkg/apis/duck/v1"
3940
"knative.dev/pkg/controller"
4041
"knative.dev/pkg/logging"
4142
)
@@ -195,6 +196,17 @@ func IsHttpsSink(sink string) bool {
195196
return strings.EqualFold(s.Scheme, "https")
196197
}
197198

199+
// GetHttpsAddress returns the (first) https address out of the list of addresses
200+
func GetHttpsAddress(addresses []duckv1.Addressable) *duckv1.Addressable {
201+
for _, address := range addresses {
202+
if IsHttpsSink(address.URL.String()) {
203+
return &address
204+
}
205+
}
206+
207+
return nil
208+
}
209+
198210
// certPool returns a x509.CertPool with the combined certs from:
199211
// - the system cert pool
200212
// - the knative trust bundle in TrustBundleMountPath
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
Copyright 2019 The Knative Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package utils
18+
19+
import (
20+
"net/http"
21+
"strings"
22+
23+
"k8s.io/apimachinery/pkg/util/sets"
24+
)
25+
26+
// TODO make propagated headers/prefixes configurable (configmap?)
27+
28+
var (
29+
// These MUST be lowercase strings, as they will be compared against lowercase strings.
30+
forwardHeaders = sets.NewString(
31+
"x-request-id", // tracing
32+
"retry-after",
33+
)
34+
// These MUST be lowercase strings, as they will be compared against lowercase strings.
35+
// Removing CloudEvents ce- prefixes on purpose as they should be set in the CloudEvent itself as extensions.
36+
// Then the SDK will set them as ce- headers when sending them through HTTP. Otherwise, when using replies we would
37+
// duplicate ce- headers.
38+
forwardPrefixes = []string{
39+
"knative-", // Knative
40+
"x-b3-", // Zipkin (Istio) B3
41+
}
42+
)
43+
44+
// PassThroughHeaders extracts the headers from headers that are in the `forwardHeaders` set
45+
// or has any of the prefixes in `forwardPrefixes`.
46+
func PassThroughHeaders(headers http.Header) http.Header {
47+
h := http.Header{}
48+
49+
for n, v := range headers {
50+
lower := strings.ToLower(n)
51+
if forwardHeaders.Has(lower) {
52+
h[n] = v
53+
continue
54+
}
55+
for _, prefix := range forwardPrefixes {
56+
if strings.HasPrefix(lower, prefix) {
57+
h[n] = v
58+
break
59+
}
60+
}
61+
}
62+
return h
63+
}

0 commit comments

Comments
 (0)