Skip to content

Commit

Permalink
Add triggers OIDC identity to Reply & DLS requests (#7481)
Browse files Browse the repository at this point in the history
Fix boilerplate header

Add metrics to reply & DLS requests and refactor

Add e2e test

Fix broker to setup its own delivery status

Fix trigger reconciler to not update broker spec

Add reply test

Address review comments
  • Loading branch information
creydr authored Dec 4, 2023
1 parent 79bb385 commit 6abe85b
Show file tree
Hide file tree
Showing 27 changed files with 704 additions and 131 deletions.
3 changes: 2 additions & 1 deletion cmd/broker/filter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"knative.dev/eventing/pkg/apis/feature"
"knative.dev/eventing/pkg/auth"
"knative.dev/eventing/pkg/broker/filter"
brokerinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1/broker"
triggerinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1/trigger"
"knative.dev/eventing/pkg/reconciler/names"
)
Expand Down Expand Up @@ -125,7 +126,7 @@ func main() {
// We are running both the receiver (takes messages in from the Broker) and the dispatcher (send
// the messages to the triggers' subscribers) in this binary.
oidcTokenVerifier := auth.NewOIDCTokenVerifier(ctx)
handler, err := filter.NewHandler(logger, oidcTokenVerifier, oidcTokenProvider, triggerinformer.Get(ctx), reporter, ctxFunc)
handler, err := filter.NewHandler(logger, oidcTokenVerifier, oidcTokenProvider, triggerinformer.Get(ctx), brokerinformer.Get(ctx), reporter, ctxFunc)
if err != nil {
logger.Fatal("Error creating Handler", zap.Error(err))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ rules:
- apiGroups:
- eventing.knative.dev
resources:
- brokers
- brokers/status
- triggers
- triggers/status
verbs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ spec:
deadLetterSinkCACerts:
description: Certification Authority (CA) certificates in PEM format according to https://www.rfc-editor.org/rfc/rfc7468.
type: string
deadLetterSinkAudience:
description: OIDC audience of the dead letter sink.
type: string
observedGeneration:
description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/core/resources/broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ spec:
deadLetterSinkCACerts:
description: Certification Authority (CA) certificates in PEM format according to https://www.rfc-editor.org/rfc/rfc7468.
type: string
deadLetterSinkAudience:
description: OIDC audience of the dead letter sink.
type: string
observedGeneration:
description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/core/resources/channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ spec:
deadLetterSinkCACerts:
description: Certification Authority (CA) certificates in PEM format according to https://www.rfc-editor.org/rfc/rfc7468.
type: string
deadLetterSinkAudience:
description: OIDC audience of the dead letter sink.
type: string
observedGeneration:
description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
type: integer
Expand Down
3 changes: 3 additions & 0 deletions config/core/resources/subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ spec:
deadLetterSinkCACerts:
description: Certification Authority (CA) certificates in PEM format according to https://www.rfc-editor.org/rfc/rfc7468.
type: string
deadLetterSinkAudience:
description: OIDC audience of the dead letter sink.
type: string
replyUri:
description: ReplyURI is the fully resolved URI for the spec.reply.
type: string
Expand Down
3 changes: 3 additions & 0 deletions config/core/resources/trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ spec:
deadLetterSinkCACerts:
description: Certification Authority (CA) certificates in PEM format according to https://www.rfc-editor.org/rfc/rfc7468.
type: string
deadLetterSinkAudience:
description: OIDC audience of the dead letter sink.
type: string
observedGeneration:
description: ObservedGeneration is the 'Generation' of the Service that was last processed by the controller.
type: integer
Expand Down
12 changes: 12 additions & 0 deletions docs/eventing-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,18 @@ string
according to <a href="https://www.rfc-editor.org/rfc/rfc7468">https://www.rfc-editor.org/rfc/rfc7468</a>.</p>
</td>
</tr>
<tr>
<td>
<code>deadLetterSinkAudience</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>DeadLetterSinkAudience is the OIDC audience of the DeadLetterSink</p>
</td>
</tr>
</tbody>
</table>
<h3 id="duck.knative.dev/v1.Subscribable">Subscribable
Expand Down
13 changes: 9 additions & 4 deletions pkg/apis/duck/v1/delivery_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ type DeliveryStatus struct {
// according to https://www.rfc-editor.org/rfc/rfc7468.
// +optional
DeadLetterSinkCACerts *string `json:"deadLetterSinkCACerts,omitempty"`
// DeadLetterSinkAudience is the OIDC audience of the DeadLetterSink
// +optional
DeadLetterSinkAudience *string `json:"deadLetterSinkAudience,omitempty"`
}

func (ds *DeliveryStatus) IsSet() bool {
Expand All @@ -166,14 +169,16 @@ func (ds *DeliveryStatus) IsSet() bool {

func NewDeliveryStatusFromAddressable(addr *duckv1.Addressable) DeliveryStatus {
return DeliveryStatus{
DeadLetterSinkURI: addr.URL,
DeadLetterSinkCACerts: addr.CACerts,
DeadLetterSinkURI: addr.URL,
DeadLetterSinkCACerts: addr.CACerts,
DeadLetterSinkAudience: addr.Audience,
}
}

func NewDestinationFromDeliveryStatus(status DeliveryStatus) duckv1.Destination {
return duckv1.Destination{
URI: status.DeadLetterSinkURI,
CACerts: status.DeadLetterSinkCACerts,
URI: status.DeadLetterSinkURI,
CACerts: status.DeadLetterSinkCACerts,
Audience: status.DeadLetterSinkAudience,
}
}
5 changes: 5 additions & 0 deletions pkg/apis/duck/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6abe85b

Please sign in to comment.