fix(oidc): don't push introspection client events (#8481)

# Which Problems Are Solved

Do not push secret succeeded and failed events for API and OIDC clients
on the introspection endpoint.
On instances where introspection was fequently called, the pushed events
created issues on duplicate primary keys, due to collisions on the
`sequence` column in the eventstore. As the event pusher retries on this
collision and we pushed above mentioned events async, it would create a
backpressure of concurrent pushers and effectively cripple an instance.

We considered that pushing these events have little value with regards
to the audit trail, as we do not push similar events when client
assertion is used. Also, before #7657 the events were defined, but not
pushed.

# How the Problems Are Solved

- Removed API secret check succeeded and faild event definitions
- Removed OIDC secret check succeeded and faild event definitions
- Push only Hash Updated event when needed

# Additional Changes

- None

# Additional Context

- Fixes https://github.com/zitadel/zitadel/issues/8479
- Closes https://github.com/zitadel/zitadel/issues/8430
- Intoduced in https://github.com/zitadel/zitadel/pull/7657
This commit is contained in:
Tim Möhlmann
2024-08-28 20:19:50 +02:00
committed by GitHub
parent ca8f82423a
commit 90b908c361
9 changed files with 38 additions and 256 deletions

View File

@@ -10,12 +10,10 @@ import (
)
const (
APIConfigAddedType = applicationEventTypePrefix + "config.api.added"
APIConfigChangedType = applicationEventTypePrefix + "config.api.changed"
APIConfigSecretChangedType = applicationEventTypePrefix + "config.api.secret.changed"
APIClientSecretCheckSucceededType = applicationEventTypePrefix + "api.secret.check.succeeded"
APIClientSecretCheckFailedType = applicationEventTypePrefix + "api.secret.check.failed"
APIConfigSecretHashUpdatedType = applicationEventTypePrefix + "config.api.secret.updated"
APIConfigAddedType = applicationEventTypePrefix + "config.api.added"
APIConfigChangedType = applicationEventTypePrefix + "config.api.changed"
APIConfigSecretChangedType = applicationEventTypePrefix + "config.api.secret.changed"
APIConfigSecretHashUpdatedType = applicationEventTypePrefix + "config.api.secret.updated"
)
type APIConfigAddedEvent struct {
@@ -202,90 +200,6 @@ func APIConfigSecretChangedEventMapper(event eventstore.Event) (eventstore.Event
return e, nil
}
type APIConfigSecretCheckSucceededEvent struct {
eventstore.BaseEvent `json:"-"`
AppID string `json:"appId"`
}
func (e *APIConfigSecretCheckSucceededEvent) Payload() interface{} {
return e
}
func (e *APIConfigSecretCheckSucceededEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
func NewAPIConfigSecretCheckSucceededEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
appID string,
) *APIConfigSecretCheckSucceededEvent {
return &APIConfigSecretCheckSucceededEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
aggregate,
APIClientSecretCheckSucceededType,
),
AppID: appID,
}
}
func APIConfigSecretCheckSucceededEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &APIConfigSecretCheckSucceededEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := event.Unmarshal(e)
if err != nil {
return nil, zerrors.ThrowInternal(err, "API-837gV", "unable to unmarshal api config")
}
return e, nil
}
type APIConfigSecretCheckFailedEvent struct {
eventstore.BaseEvent `json:"-"`
AppID string `json:"appId"`
}
func (e *APIConfigSecretCheckFailedEvent) Payload() interface{} {
return e
}
func (e *APIConfigSecretCheckFailedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
return nil
}
func NewAPIConfigSecretCheckFailedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
appID string,
) *APIConfigSecretCheckFailedEvent {
return &APIConfigSecretCheckFailedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
aggregate,
APIClientSecretCheckFailedType,
),
AppID: appID,
}
}
func APIConfigSecretCheckFailedEventMapper(event eventstore.Event) (eventstore.Event, error) {
e := &APIConfigSecretCheckFailedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
}
err := event.Unmarshal(e)
if err != nil {
return nil, zerrors.ThrowInternal(err, "API-987g%", "unable to unmarshal api config")
}
return e, nil
}
type APIConfigSecretHashUpdatedEvent struct {
*eventstore.BaseEvent `json:"-"`