diff --git a/internal/admin/repository/eventsourcing/handler/custom_text.go b/internal/admin/repository/eventsourcing/handler/custom_text.go index 4d6ceef2d..8a2d8697a 100644 --- a/internal/admin/repository/eventsourcing/handler/custom_text.go +++ b/internal/admin/repository/eventsourcing/handler/custom_text.go @@ -40,6 +40,10 @@ const ( customTextTable = "adminapi.custom_texts" ) +func (m *CustomText) Subscription() *v1.Subscription { + return m.subscription +} + func (m *CustomText) ViewModel() string { return customTextTable } diff --git a/internal/admin/repository/eventsourcing/handler/features.go b/internal/admin/repository/eventsourcing/handler/features.go index da1671ddb..408864e48 100644 --- a/internal/admin/repository/eventsourcing/handler/features.go +++ b/internal/admin/repository/eventsourcing/handler/features.go @@ -47,6 +47,10 @@ func (p *Features) subscribe() { }() } +func (p *Features) Subscription() *v1.Subscription { + return p.subscription +} + func (p *Features) ViewModel() string { return featuresTable } diff --git a/internal/admin/repository/eventsourcing/handler/iam_member.go b/internal/admin/repository/eventsourcing/handler/iam_member.go index 10ccb7fd5..0dcce47b6 100644 --- a/internal/admin/repository/eventsourcing/handler/iam_member.go +++ b/internal/admin/repository/eventsourcing/handler/iam_member.go @@ -49,7 +49,6 @@ func (m *IAMMember) subscribe() { go func() { for event := range m.subscription.Events { - query.ReduceEvent(m, event) } }() @@ -67,6 +66,10 @@ func (m *IAMMember) ViewModel() string { return iamMemberTable } +func (m *IAMMember) Subscription() *v1.Subscription { + return m.subscription +} + func (m *IAMMember) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.IAMAggregate, usr_es_model.UserAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/idp_config.go b/internal/admin/repository/eventsourcing/handler/idp_config.go index a45e99f64..d815ac5a2 100644 --- a/internal/admin/repository/eventsourcing/handler/idp_config.go +++ b/internal/admin/repository/eventsourcing/handler/idp_config.go @@ -39,6 +39,10 @@ func (i *IDPConfig) subscribe() { }() } +func (i *IDPConfig) Subscription() *v1.Subscription { + return i.subscription +} + func (i *IDPConfig) ViewModel() string { return idpConfigTable } diff --git a/internal/admin/repository/eventsourcing/handler/idp_providers.go b/internal/admin/repository/eventsourcing/handler/idp_providers.go index 572119f67..2cfd435a3 100644 --- a/internal/admin/repository/eventsourcing/handler/idp_providers.go +++ b/internal/admin/repository/eventsourcing/handler/idp_providers.go @@ -54,6 +54,10 @@ func (i *IDPProvider) subscribe() { }() } +func (i *IDPProvider) Subscription() *v1.Subscription { + return i.subscription +} + func (i *IDPProvider) ViewModel() string { return idpProviderTable } diff --git a/internal/admin/repository/eventsourcing/handler/label_policy.go b/internal/admin/repository/eventsourcing/handler/label_policy.go index b5c6a4aba..c54c39be9 100644 --- a/internal/admin/repository/eventsourcing/handler/label_policy.go +++ b/internal/admin/repository/eventsourcing/handler/label_policy.go @@ -44,6 +44,10 @@ func (p *LabelPolicy) ViewModel() string { return labelPolicyTable } +func (p *LabelPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *LabelPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/login_policy.go b/internal/admin/repository/eventsourcing/handler/login_policy.go index 7eb91ba2d..0c1b818be 100644 --- a/internal/admin/repository/eventsourcing/handler/login_policy.go +++ b/internal/admin/repository/eventsourcing/handler/login_policy.go @@ -2,7 +2,9 @@ package handler import ( "context" + "github.com/caos/logging" + "github.com/caos/zitadel/internal/domain" caos_errs "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/eventstore/v1" @@ -12,7 +14,7 @@ import ( "github.com/caos/zitadel/internal/iam/repository/eventsourcing" iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model" iam_model "github.com/caos/zitadel/internal/iam/repository/view/model" - model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model" + "github.com/caos/zitadel/internal/org/repository/eventsourcing/model" ) const ( @@ -47,6 +49,10 @@ func (p *LoginPolicy) ViewModel() string { return loginPolicyTable } +func (p *LoginPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *LoginPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, model.OrgAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/mail_template.go b/internal/admin/repository/eventsourcing/handler/mail_template.go index 6117449f4..8af4968d3 100644 --- a/internal/admin/repository/eventsourcing/handler/mail_template.go +++ b/internal/admin/repository/eventsourcing/handler/mail_template.go @@ -44,12 +44,16 @@ func (m *MailTemplate) ViewModel() string { return mailTemplateTable } -func (_ *MailTemplate) AggregateTypes() []es_models.AggregateType { +func (m *MailTemplate) Subscription() *v1.Subscription { + return m.subscription +} + +func (m *MailTemplate) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate} } -func (p *MailTemplate) CurrentSequence() (uint64, error) { - sequence, err := p.view.GetLatestMailTemplateSequence() +func (m *MailTemplate) CurrentSequence() (uint64, error) { + sequence, err := m.view.GetLatestMailTemplateSequence() if err != nil { return 0, err } @@ -99,6 +103,6 @@ func (m *MailTemplate) OnError(event *es_models.Event, err error) error { return spooler.HandleError(event, err, m.view.GetLatestMailTemplateFailedEvent, m.view.ProcessedMailTemplateFailedEvent, m.view.ProcessedMailTemplateSequence, m.errorCountUntilSkip) } -func (o *MailTemplate) OnSuccess() error { - return spooler.HandleSuccess(o.view.UpdateMailTemplateSpoolerRunTimestamp) +func (m *MailTemplate) OnSuccess() error { + return spooler.HandleSuccess(m.view.UpdateMailTemplateSpoolerRunTimestamp) } diff --git a/internal/admin/repository/eventsourcing/handler/message_text.go b/internal/admin/repository/eventsourcing/handler/message_text.go index 8bdb17ea1..05083427e 100644 --- a/internal/admin/repository/eventsourcing/handler/message_text.go +++ b/internal/admin/repository/eventsourcing/handler/message_text.go @@ -2,6 +2,7 @@ package handler import ( "github.com/caos/logging" + caos_errs "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/eventstore/v1" @@ -45,6 +46,10 @@ func (m *MessageText) ViewModel() string { return mailTextTable } +func (m *MessageText) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *MessageText) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/org.go b/internal/admin/repository/eventsourcing/handler/org.go index 42e741488..be3682a96 100644 --- a/internal/admin/repository/eventsourcing/handler/org.go +++ b/internal/admin/repository/eventsourcing/handler/org.go @@ -44,6 +44,10 @@ func (o *Org) ViewModel() string { return orgTable } +func (o *Org) Subscription() *v1.Subscription { + return o.subscription +} + func (o *Org) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/org_iam_policy.go b/internal/admin/repository/eventsourcing/handler/org_iam_policy.go index d1beeab5f..5b32c8f6b 100644 --- a/internal/admin/repository/eventsourcing/handler/org_iam_policy.go +++ b/internal/admin/repository/eventsourcing/handler/org_iam_policy.go @@ -2,6 +2,7 @@ package handler import ( "github.com/caos/logging" + "github.com/caos/zitadel/internal/eventstore/v1" es_models "github.com/caos/zitadel/internal/eventstore/v1/models" "github.com/caos/zitadel/internal/eventstore/v1/query" @@ -43,6 +44,10 @@ func (p *OrgIAMPolicy) ViewModel() string { return orgIAMPolicyTable } +func (p *OrgIAMPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *OrgIAMPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/password_age_policy.go b/internal/admin/repository/eventsourcing/handler/password_age_policy.go index d1a0be0d1..66065cc2e 100644 --- a/internal/admin/repository/eventsourcing/handler/password_age_policy.go +++ b/internal/admin/repository/eventsourcing/handler/password_age_policy.go @@ -2,6 +2,7 @@ package handler import ( "github.com/caos/logging" + "github.com/caos/zitadel/internal/eventstore/v1" iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model" @@ -44,6 +45,10 @@ func (p *PasswordAgePolicy) ViewModel() string { return passwordAgePolicyTable } +func (p *PasswordAgePolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *PasswordAgePolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/password_complexity_policy.go b/internal/admin/repository/eventsourcing/handler/password_complexity_policy.go index 221325ead..51e67d232 100644 --- a/internal/admin/repository/eventsourcing/handler/password_complexity_policy.go +++ b/internal/admin/repository/eventsourcing/handler/password_complexity_policy.go @@ -2,6 +2,7 @@ package handler import ( "github.com/caos/logging" + "github.com/caos/zitadel/internal/eventstore/v1" iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model" @@ -44,6 +45,10 @@ func (p *PasswordComplexityPolicy) ViewModel() string { return passwordComplexityPolicyTable } +func (m *PasswordComplexityPolicy) Subscription() *v1.Subscription { + return m.subscription +} + func (p *PasswordComplexityPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/password_lockout_policy.go b/internal/admin/repository/eventsourcing/handler/password_lockout_policy.go index d04a50772..39aefbb0b 100644 --- a/internal/admin/repository/eventsourcing/handler/password_lockout_policy.go +++ b/internal/admin/repository/eventsourcing/handler/password_lockout_policy.go @@ -44,6 +44,10 @@ func (p *PasswordLockoutPolicy) ViewModel() string { return passwordLockoutPolicyTable } +func (m *PasswordLockoutPolicy) Subscription() *v1.Subscription { + return m.subscription +} + func (p *PasswordLockoutPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/privacy_policy.go b/internal/admin/repository/eventsourcing/handler/privacy_policy.go index 9620de9f4..0b842eb7e 100644 --- a/internal/admin/repository/eventsourcing/handler/privacy_policy.go +++ b/internal/admin/repository/eventsourcing/handler/privacy_policy.go @@ -44,6 +44,10 @@ func (p *PrivacyPolicy) ViewModel() string { return privacyPolicyTable } +func (p *PrivacyPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *PrivacyPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/styling.go b/internal/admin/repository/eventsourcing/handler/styling.go index cee90d725..f449098d2 100644 --- a/internal/admin/repository/eventsourcing/handler/styling.go +++ b/internal/admin/repository/eventsourcing/handler/styling.go @@ -63,6 +63,10 @@ func (m *Styling) ViewModel() string { return stylingTable } +func (m *Styling) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *Styling) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/user.go b/internal/admin/repository/eventsourcing/handler/user.go index d0731e954..4427c3e89 100644 --- a/internal/admin/repository/eventsourcing/handler/user.go +++ b/internal/admin/repository/eventsourcing/handler/user.go @@ -60,6 +60,10 @@ func (u *User) ViewModel() string { return userTable } +func (u *User) Subscription() *v1.Subscription { + return u.subscription +} + func (u *User) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{es_model.UserAggregate, org_es_model.OrgAggregate} } diff --git a/internal/admin/repository/eventsourcing/handler/user_external_idps.go b/internal/admin/repository/eventsourcing/handler/user_external_idps.go index 02d9e1ba2..0cb37fa07 100644 --- a/internal/admin/repository/eventsourcing/handler/user_external_idps.go +++ b/internal/admin/repository/eventsourcing/handler/user_external_idps.go @@ -59,6 +59,10 @@ func (i *ExternalIDP) ViewModel() string { return externalIDPTable } +func (i *ExternalIDP) Subscription() *v1.Subscription { + return i.subscription +} + func (i *ExternalIDP) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.UserAggregate, iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/api/api.go b/internal/api/api.go index ef12ff5f6..e7b5225e9 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -8,6 +8,7 @@ import ( "github.com/caos/zitadel/internal/telemetry/metrics" "github.com/caos/zitadel/internal/telemetry/metrics/otel" view_model "github.com/caos/zitadel/internal/view/model" + sentryhttp "github.com/getsentry/sentry-go/http" "go.opentelemetry.io/otel/api/metric" "net/http" @@ -78,7 +79,8 @@ func (a *API) RegisterServer(ctx context.Context, server server.Server) { } func (a *API) RegisterHandler(prefix string, handler http.Handler) { - a.gatewayHandler.RegisterHandler(prefix, handler) + sentryHandler := sentryhttp.New(sentryhttp.Options{}) + a.gatewayHandler.RegisterHandler(prefix, sentryHandler.Handle(handler)) } func (a *API) Start(ctx context.Context) { diff --git a/internal/auth/repository/eventsourcing/handler/application.go b/internal/auth/repository/eventsourcing/handler/application.go index 3b56bc67a..7ef1d6fbb 100644 --- a/internal/auth/repository/eventsourcing/handler/application.go +++ b/internal/auth/repository/eventsourcing/handler/application.go @@ -49,6 +49,10 @@ func (a *Application) ViewModel() string { return applicationTable } +func (a *Application) Subscription() *v1.Subscription { + return a.subscription +} + func (_ *Application) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/authn_keys.go b/internal/auth/repository/eventsourcing/handler/authn_keys.go index f7a2fdf69..6e485ac72 100644 --- a/internal/auth/repository/eventsourcing/handler/authn_keys.go +++ b/internal/auth/repository/eventsourcing/handler/authn_keys.go @@ -46,6 +46,10 @@ func (k *AuthNKeys) ViewModel() string { return authnKeysTable } +func (k *AuthNKeys) Subscription() *v1.Subscription { + return k.subscription +} + func (_ *AuthNKeys) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{user_model.UserAggregate, proj_model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/custom_text.go b/internal/auth/repository/eventsourcing/handler/custom_text.go index f17a2e6ad..1cc457ddf 100644 --- a/internal/auth/repository/eventsourcing/handler/custom_text.go +++ b/internal/auth/repository/eventsourcing/handler/custom_text.go @@ -44,6 +44,10 @@ func (m *CustomText) ViewModel() string { return customTextTable } +func (m *CustomText) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *CustomText) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/features.go b/internal/auth/repository/eventsourcing/handler/features.go index b02564952..5775f8845 100644 --- a/internal/auth/repository/eventsourcing/handler/features.go +++ b/internal/auth/repository/eventsourcing/handler/features.go @@ -51,6 +51,10 @@ func (p *Features) ViewModel() string { return featuresTable } +func (p *Features) Subscription() *v1.Subscription { + return p.subscription +} + func (p *Features) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/idp_config.go b/internal/auth/repository/eventsourcing/handler/idp_config.go index 225d1b208..20798e26e 100644 --- a/internal/auth/repository/eventsourcing/handler/idp_config.go +++ b/internal/auth/repository/eventsourcing/handler/idp_config.go @@ -44,6 +44,10 @@ func (i *IDPConfig) ViewModel() string { return idpConfigTable } +func (i *IDPConfig) Subscription() *v1.Subscription { + return i.subscription +} + func (_ *IDPConfig) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/idp_providers.go b/internal/auth/repository/eventsourcing/handler/idp_providers.go index 3b104ab4f..442e03b8a 100644 --- a/internal/auth/repository/eventsourcing/handler/idp_providers.go +++ b/internal/auth/repository/eventsourcing/handler/idp_providers.go @@ -59,6 +59,10 @@ func (i *IDPProvider) ViewModel() string { return idpProviderTable } +func (i *IDPProvider) Subscription() *v1.Subscription { + return i.subscription +} + func (_ *IDPProvider) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/key.go b/internal/auth/repository/eventsourcing/handler/key.go index 4c72a1733..372533c0c 100644 --- a/internal/auth/repository/eventsourcing/handler/key.go +++ b/internal/auth/repository/eventsourcing/handler/key.go @@ -49,6 +49,10 @@ func (k *Key) ViewModel() string { return keyTable } +func (k *Key) Subscription() *v1.Subscription { + return k.subscription +} + func (_ *Key) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.KeyPairAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/label_policy.go b/internal/auth/repository/eventsourcing/handler/label_policy.go index 2759e609d..a00ac4a9e 100644 --- a/internal/auth/repository/eventsourcing/handler/label_policy.go +++ b/internal/auth/repository/eventsourcing/handler/label_policy.go @@ -46,6 +46,10 @@ func (m *LabelPolicy) ViewModel() string { return labelPolicyTable } +func (p *LabelPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *LabelPolicy) AggregateTypes() []models.AggregateType { return []models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/login_policy.go b/internal/auth/repository/eventsourcing/handler/login_policy.go index 3e577b7f4..34f2aa976 100644 --- a/internal/auth/repository/eventsourcing/handler/login_policy.go +++ b/internal/auth/repository/eventsourcing/handler/login_policy.go @@ -48,6 +48,10 @@ func (p *LoginPolicy) ViewModel() string { return loginPolicyTable } +func (p *LoginPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *LoginPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/org.go b/internal/auth/repository/eventsourcing/handler/org.go index e330aa0d5..70990ef9e 100644 --- a/internal/auth/repository/eventsourcing/handler/org.go +++ b/internal/auth/repository/eventsourcing/handler/org.go @@ -44,6 +44,10 @@ func (o *Org) ViewModel() string { return orgTable } +func (o *Org) Subscription() *v1.Subscription { + return o.subscription +} + func (_ *Org) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/org_iam_policy.go b/internal/auth/repository/eventsourcing/handler/org_iam_policy.go index 6fa4a729d..8357b5589 100644 --- a/internal/auth/repository/eventsourcing/handler/org_iam_policy.go +++ b/internal/auth/repository/eventsourcing/handler/org_iam_policy.go @@ -44,6 +44,10 @@ func (p *OrgIAMPolicy) ViewModel() string { return orgIAMPolicyTable } +func (p *OrgIAMPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *OrgIAMPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{org_es_model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/password_complexity_policy.go b/internal/auth/repository/eventsourcing/handler/password_complexity_policy.go index 25ed11aae..f50b16e49 100644 --- a/internal/auth/repository/eventsourcing/handler/password_complexity_policy.go +++ b/internal/auth/repository/eventsourcing/handler/password_complexity_policy.go @@ -44,6 +44,10 @@ func (p *PasswordComplexityPolicy) ViewModel() string { return passwordComplexityPolicyTable } +func (p *PasswordComplexityPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *PasswordComplexityPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{org_es_model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/privacy_policy.go b/internal/auth/repository/eventsourcing/handler/privacy_policy.go index f79a036dd..4240f1c1f 100644 --- a/internal/auth/repository/eventsourcing/handler/privacy_policy.go +++ b/internal/auth/repository/eventsourcing/handler/privacy_policy.go @@ -44,6 +44,10 @@ func (p *PrivacyPolicy) ViewModel() string { return privacyPolicyTable } +func (p *PrivacyPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *PrivacyPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/project_role.go b/internal/auth/repository/eventsourcing/handler/project_role.go index 6c7f16c13..a63ff3436 100644 --- a/internal/auth/repository/eventsourcing/handler/project_role.go +++ b/internal/auth/repository/eventsourcing/handler/project_role.go @@ -46,6 +46,10 @@ func (p *ProjectRole) ViewModel() string { return projectRoleTable } +func (p *ProjectRole) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *ProjectRole) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/refresh_token.go b/internal/auth/repository/eventsourcing/handler/refresh_token.go index e88a2b632..6b2cd1978 100644 --- a/internal/auth/repository/eventsourcing/handler/refresh_token.go +++ b/internal/auth/repository/eventsourcing/handler/refresh_token.go @@ -51,6 +51,10 @@ func (t *RefreshToken) ViewModel() string { return refreshTokenTable } +func (t *RefreshToken) Subscription() *v1.Subscription { + return t.subscription +} + func (t *RefreshToken) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{user_es_model.UserAggregate, project_es_model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/token.go b/internal/auth/repository/eventsourcing/handler/token.go index c1b05e0fa..596cd56e4 100644 --- a/internal/auth/repository/eventsourcing/handler/token.go +++ b/internal/auth/repository/eventsourcing/handler/token.go @@ -53,6 +53,10 @@ func (t *Token) ViewModel() string { return tokenTable } +func (t *Token) Subscription() *v1.Subscription { + return t.subscription +} + func (_ *Token) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{user_es_model.UserAggregate, project_es_model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/user.go b/internal/auth/repository/eventsourcing/handler/user.go index 212c66078..d3e88e042 100644 --- a/internal/auth/repository/eventsourcing/handler/user.go +++ b/internal/auth/repository/eventsourcing/handler/user.go @@ -57,6 +57,9 @@ func (u *User) ViewModel() string { return userTable } +func (u *User) Subscription() *v1.Subscription { + return u.subscription +} func (_ *User) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{es_model.UserAggregate, org_es_model.OrgAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/user_external_idps.go b/internal/auth/repository/eventsourcing/handler/user_external_idps.go index b3c4c1796..a5b71dd11 100644 --- a/internal/auth/repository/eventsourcing/handler/user_external_idps.go +++ b/internal/auth/repository/eventsourcing/handler/user_external_idps.go @@ -59,6 +59,10 @@ func (i *ExternalIDP) ViewModel() string { return externalIDPTable } +func (i *ExternalIDP) Subscription() *v1.Subscription { + return i.subscription +} + func (_ *ExternalIDP) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.UserAggregate, iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/user_grant.go b/internal/auth/repository/eventsourcing/handler/user_grant.go index 4296a9520..96fb693a0 100644 --- a/internal/auth/repository/eventsourcing/handler/user_grant.go +++ b/internal/auth/repository/eventsourcing/handler/user_grant.go @@ -71,6 +71,10 @@ func (u *UserGrant) ViewModel() string { return userGrantTable } +func (u *UserGrant) Subscription() *v1.Subscription { + return u.subscription +} + func (_ *UserGrant) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{grant_es_model.UserGrantAggregate, iam_es_model.IAMAggregate, org_es_model.OrgAggregate, usr_es_model.UserAggregate, proj_es_model.ProjectAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/user_membership.go b/internal/auth/repository/eventsourcing/handler/user_membership.go index d867b3a97..ca3f27adb 100644 --- a/internal/auth/repository/eventsourcing/handler/user_membership.go +++ b/internal/auth/repository/eventsourcing/handler/user_membership.go @@ -57,6 +57,10 @@ func (m *UserMembership) ViewModel() string { return userMembershipTable } +func (m *UserMembership) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *UserMembership) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate, proj_es_model.ProjectAggregate, model.UserAggregate} } diff --git a/internal/auth/repository/eventsourcing/handler/user_session.go b/internal/auth/repository/eventsourcing/handler/user_session.go index 63f83133b..4b9cede17 100644 --- a/internal/auth/repository/eventsourcing/handler/user_session.go +++ b/internal/auth/repository/eventsourcing/handler/user_session.go @@ -47,6 +47,10 @@ func (u *UserSession) ViewModel() string { return userSessionTable } +func (u *UserSession) Subscription() *v1.Subscription { + return u.subscription +} + func (_ *UserSession) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.UserAggregate} } diff --git a/internal/authz/repository/eventsourcing/handler/application.go b/internal/authz/repository/eventsourcing/handler/application.go index ceb818caf..c70798506 100644 --- a/internal/authz/repository/eventsourcing/handler/application.go +++ b/internal/authz/repository/eventsourcing/handler/application.go @@ -44,6 +44,10 @@ func (a *Application) ViewModel() string { return applicationTable } +func (p *Application) Subscription() *v1.Subscription { + return p.subscription +} + func (a *Application) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/authz/repository/eventsourcing/handler/features.go b/internal/authz/repository/eventsourcing/handler/features.go index c558acd38..86b2d0bdc 100644 --- a/internal/authz/repository/eventsourcing/handler/features.go +++ b/internal/authz/repository/eventsourcing/handler/features.go @@ -51,6 +51,10 @@ func (p *Features) ViewModel() string { return featuresTable } +func (p *Features) Subscription() *v1.Subscription { + return p.subscription +} + func (p *Features) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/authz/repository/eventsourcing/handler/org.go b/internal/authz/repository/eventsourcing/handler/org.go index 62bc9ec05..aca287fd4 100644 --- a/internal/authz/repository/eventsourcing/handler/org.go +++ b/internal/authz/repository/eventsourcing/handler/org.go @@ -44,6 +44,10 @@ func (o *Org) ViewModel() string { return orgTable } +func (o *Org) Subscription() *v1.Subscription { + return o.subscription +} + func (_ *Org) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate} } diff --git a/internal/authz/repository/eventsourcing/handler/user_grant.go b/internal/authz/repository/eventsourcing/handler/user_grant.go index e392dcfb3..3c3fea47e 100644 --- a/internal/authz/repository/eventsourcing/handler/user_grant.go +++ b/internal/authz/repository/eventsourcing/handler/user_grant.go @@ -60,6 +60,10 @@ func (u *UserGrant) ViewModel() string { return userGrantTable } +func (u *UserGrant) Subscription() *v1.Subscription { + return u.subscription +} + func (_ *UserGrant) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate, proj_es_model.ProjectAggregate} } diff --git a/internal/authz/repository/eventsourcing/handler/user_membership.go b/internal/authz/repository/eventsourcing/handler/user_membership.go index 2c67623ea..c6dbf9dc7 100644 --- a/internal/authz/repository/eventsourcing/handler/user_membership.go +++ b/internal/authz/repository/eventsourcing/handler/user_membership.go @@ -57,6 +57,10 @@ func (m *UserMembership) ViewModel() string { return userMembershipTable } +func (m *UserMembership) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *UserMembership) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate, proj_es_model.ProjectAggregate, model.UserAggregate} } diff --git a/internal/eventstore/v1/query/handler.go b/internal/eventstore/v1/query/handler.go index a04a58528..e9f5600fc 100755 --- a/internal/eventstore/v1/query/handler.go +++ b/internal/eventstore/v1/query/handler.go @@ -2,9 +2,12 @@ package query import ( "context" - "github.com/caos/zitadel/internal/eventstore/v1" "time" + "github.com/getsentry/sentry-go" + + "github.com/caos/zitadel/internal/eventstore/v1" + "github.com/caos/logging" "github.com/caos/zitadel/internal/eventstore/v1/models" @@ -27,9 +30,19 @@ type Handler interface { AggregateTypes() []models.AggregateType CurrentSequence() (uint64, error) Eventstore() v1.Eventstore + + Subscription() *v1.Subscription } func ReduceEvent(handler Handler, event *models.Event) { + defer func() { + err := recover() + + if err != nil { + sentry.CurrentHub().Recover(err) + handler.Subscription().Unsubscribe() + } + }() currentSequence, err := handler.CurrentSequence() if err != nil { logging.Log("HANDL-BmpkC").WithError(err).Warn("unable to get current sequence") diff --git a/internal/eventstore/v1/spooler/spooler.go b/internal/eventstore/v1/spooler/spooler.go index b858b1122..1b632d6d5 100644 --- a/internal/eventstore/v1/spooler/spooler.go +++ b/internal/eventstore/v1/spooler/spooler.go @@ -2,6 +2,9 @@ package spooler import ( "context" + + "github.com/getsentry/sentry-go" + "github.com/caos/zitadel/internal/eventstore/v1" "strconv" "sync" @@ -64,7 +67,14 @@ func requeueTask(task *spooledHandler, queue chan<- *spooledHandler) { func (s *spooledHandler) load(workerID string) { errs := make(chan error) - defer close(errs) + defer func() { + close(errs) + err := recover() + + if err != nil { + sentry.CurrentHub().Recover(err) + } + }() ctx, cancel := context.WithCancel(context.Background()) go s.awaitError(cancel, errs, workerID) hasLocked := s.lock(ctx, errs, workerID) diff --git a/internal/eventstore/v1/spooler/spooler_test.go b/internal/eventstore/v1/spooler/spooler_test.go index eb475d93e..6b327fa7b 100644 --- a/internal/eventstore/v1/spooler/spooler_test.go +++ b/internal/eventstore/v1/spooler/spooler_test.go @@ -42,6 +42,10 @@ func (h *testHandler) ViewModel() string { return h.viewModel } +func (h *testHandler) Subscription() *v1.Subscription { + return nil +} + func (h *testHandler) EventQuery() (*models.SearchQuery, error) { if h.queryError != nil { return nil, h.queryError diff --git a/internal/management/repository/eventsourcing/handler/application.go b/internal/management/repository/eventsourcing/handler/application.go index 5ada9f92b..c7be7ecff 100644 --- a/internal/management/repository/eventsourcing/handler/application.go +++ b/internal/management/repository/eventsourcing/handler/application.go @@ -51,6 +51,10 @@ func (a *Application) ViewModel() string { return applicationTable } +func (a *Application) Subscription() *v1.Subscription { + return a.subscription +} + func (_ *Application) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/authn_keys.go b/internal/management/repository/eventsourcing/handler/authn_keys.go index b5e7e82da..82e6edb60 100644 --- a/internal/management/repository/eventsourcing/handler/authn_keys.go +++ b/internal/management/repository/eventsourcing/handler/authn_keys.go @@ -46,6 +46,10 @@ func (k *AuthNKeys) ViewModel() string { return authnKeysTable } +func (k *AuthNKeys) Subscription() *v1.Subscription { + return k.subscription +} + func (_ *AuthNKeys) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{user_model.UserAggregate, proj_model.ProjectAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/custom_text.go b/internal/management/repository/eventsourcing/handler/custom_text.go index 9409302a6..3e8f2c2eb 100644 --- a/internal/management/repository/eventsourcing/handler/custom_text.go +++ b/internal/management/repository/eventsourcing/handler/custom_text.go @@ -44,6 +44,10 @@ func (m *CustomText) ViewModel() string { return customTextTable } +func (m *CustomText) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *CustomText) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/features.go b/internal/management/repository/eventsourcing/handler/features.go index 5f4f556e6..44abb12df 100644 --- a/internal/management/repository/eventsourcing/handler/features.go +++ b/internal/management/repository/eventsourcing/handler/features.go @@ -51,6 +51,10 @@ func (p *Features) ViewModel() string { return featuresTable } +func (p *Features) Subscription() *v1.Subscription { + return p.subscription +} + func (p *Features) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/idp_config.go b/internal/management/repository/eventsourcing/handler/idp_config.go index b4a953dbc..a900e56b2 100644 --- a/internal/management/repository/eventsourcing/handler/idp_config.go +++ b/internal/management/repository/eventsourcing/handler/idp_config.go @@ -45,6 +45,10 @@ func (m *IDPConfig) ViewModel() string { return idpConfigTable } +func (m *IDPConfig) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *IDPConfig) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/idp_providers.go b/internal/management/repository/eventsourcing/handler/idp_providers.go index 71cfb70e0..00ecfb3ff 100644 --- a/internal/management/repository/eventsourcing/handler/idp_providers.go +++ b/internal/management/repository/eventsourcing/handler/idp_providers.go @@ -57,6 +57,10 @@ func (m *IDPProvider) ViewModel() string { return idpProviderTable } +func (p *IDPProvider) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *IDPProvider) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/label_policy.go b/internal/management/repository/eventsourcing/handler/label_policy.go index 0c87c5078..d7b0fb3da 100644 --- a/internal/management/repository/eventsourcing/handler/label_policy.go +++ b/internal/management/repository/eventsourcing/handler/label_policy.go @@ -50,6 +50,10 @@ func (m *LabelPolicy) ViewModel() string { return labelPolicyTable } +func (p *LabelPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *LabelPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/login_policy.go b/internal/management/repository/eventsourcing/handler/login_policy.go index f78a24780..ca5a68845 100644 --- a/internal/management/repository/eventsourcing/handler/login_policy.go +++ b/internal/management/repository/eventsourcing/handler/login_policy.go @@ -47,6 +47,10 @@ func (m *LoginPolicy) ViewModel() string { return loginPolicyTable } +func (p *LoginPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *LoginPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/mail_template.go b/internal/management/repository/eventsourcing/handler/mail_template.go index 042410e71..a165766f4 100644 --- a/internal/management/repository/eventsourcing/handler/mail_template.go +++ b/internal/management/repository/eventsourcing/handler/mail_template.go @@ -44,6 +44,10 @@ func (m *MailTemplate) ViewModel() string { return mailTemplateTable } +func (m *MailTemplate) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *MailTemplate) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/message_text.go b/internal/management/repository/eventsourcing/handler/message_text.go index 182de3127..4382ccbd6 100644 --- a/internal/management/repository/eventsourcing/handler/message_text.go +++ b/internal/management/repository/eventsourcing/handler/message_text.go @@ -44,6 +44,10 @@ func (m *MessageText) ViewModel() string { return messageTextTable } +func (m *MessageText) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *MessageText) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/org.go b/internal/management/repository/eventsourcing/handler/org.go index 2c73b4e26..0f2be8e16 100644 --- a/internal/management/repository/eventsourcing/handler/org.go +++ b/internal/management/repository/eventsourcing/handler/org.go @@ -44,6 +44,10 @@ func (o *Org) ViewModel() string { return orgTable } +func (o *Org) Subscription() *v1.Subscription { + return o.subscription +} + func (_ *Org) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/org_domain.go b/internal/management/repository/eventsourcing/handler/org_domain.go index 0f53dbeec..11e4355db 100644 --- a/internal/management/repository/eventsourcing/handler/org_domain.go +++ b/internal/management/repository/eventsourcing/handler/org_domain.go @@ -42,6 +42,10 @@ func (d *OrgDomain) ViewModel() string { return orgDomainTable } +func (d *OrgDomain) Subscription() *v1.Subscription { + return d.subscription +} + func (_ *OrgDomain) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/org_iam_policy.go b/internal/management/repository/eventsourcing/handler/org_iam_policy.go index e194e0dfa..1c9b5d13a 100644 --- a/internal/management/repository/eventsourcing/handler/org_iam_policy.go +++ b/internal/management/repository/eventsourcing/handler/org_iam_policy.go @@ -43,6 +43,10 @@ func (m *OrgIAMPolicy) ViewModel() string { return orgIAMPolicyTable } +func (m *OrgIAMPolicy) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *OrgIAMPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/org_member.go b/internal/management/repository/eventsourcing/handler/org_member.go index d46c84d2e..2b140a25c 100644 --- a/internal/management/repository/eventsourcing/handler/org_member.go +++ b/internal/management/repository/eventsourcing/handler/org_member.go @@ -58,6 +58,10 @@ func (m *OrgMember) ViewModel() string { return orgMemberTable } +func (m *OrgMember) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *OrgMember) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, usr_es_model.UserAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/password_age_policy.go b/internal/management/repository/eventsourcing/handler/password_age_policy.go index e798cfbbd..857d83078 100644 --- a/internal/management/repository/eventsourcing/handler/password_age_policy.go +++ b/internal/management/repository/eventsourcing/handler/password_age_policy.go @@ -43,6 +43,10 @@ func (m *PasswordAgePolicy) ViewModel() string { return passwordAgePolicyTable } +func (p *PasswordAgePolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *PasswordAgePolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/password_complexity_policy.go b/internal/management/repository/eventsourcing/handler/password_complexity_policy.go index 9366ea1a3..cb7575f60 100644 --- a/internal/management/repository/eventsourcing/handler/password_complexity_policy.go +++ b/internal/management/repository/eventsourcing/handler/password_complexity_policy.go @@ -43,6 +43,10 @@ func (p *PasswordComplexityPolicy) ViewModel() string { return passwordComplexityPolicyTable } +func (p *PasswordComplexityPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *PasswordComplexityPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/password_lockout_policy.go b/internal/management/repository/eventsourcing/handler/password_lockout_policy.go index a5ed4c7cd..bd9c0f0f1 100644 --- a/internal/management/repository/eventsourcing/handler/password_lockout_policy.go +++ b/internal/management/repository/eventsourcing/handler/password_lockout_policy.go @@ -44,6 +44,10 @@ func (p *PasswordLockoutPolicy) ViewModel() string { return passwordLockoutPolicyTable } +func (p *PasswordLockoutPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *PasswordLockoutPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/privacy_policy.go b/internal/management/repository/eventsourcing/handler/privacy_policy.go index 39a8fd6bd..382b74d78 100644 --- a/internal/management/repository/eventsourcing/handler/privacy_policy.go +++ b/internal/management/repository/eventsourcing/handler/privacy_policy.go @@ -44,6 +44,10 @@ func (p *PrivacyPolicy) ViewModel() string { return privacyPolicyTable } +func (p *PrivacyPolicy) Subscription() *v1.Subscription { + return p.subscription +} + func (p *PrivacyPolicy) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.OrgAggregate, iam_es_model.IAMAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/project.go b/internal/management/repository/eventsourcing/handler/project.go index a5355af28..22fb60b28 100644 --- a/internal/management/repository/eventsourcing/handler/project.go +++ b/internal/management/repository/eventsourcing/handler/project.go @@ -44,6 +44,10 @@ func (p *Project) ViewModel() string { return projectTable } +func (p *Project) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *Project) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/project_grant.go b/internal/management/repository/eventsourcing/handler/project_grant.go index 742793776..3b0366a7d 100644 --- a/internal/management/repository/eventsourcing/handler/project_grant.go +++ b/internal/management/repository/eventsourcing/handler/project_grant.go @@ -54,6 +54,10 @@ func (p *ProjectGrant) ViewModel() string { return grantedProjectTable } +func (p *ProjectGrant) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *ProjectGrant) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/project_grant_member.go b/internal/management/repository/eventsourcing/handler/project_grant_member.go index a82eaf3c6..261c1239a 100644 --- a/internal/management/repository/eventsourcing/handler/project_grant_member.go +++ b/internal/management/repository/eventsourcing/handler/project_grant_member.go @@ -61,6 +61,10 @@ func (p *ProjectGrantMember) ViewModel() string { return projectGrantMemberTable } +func (p *ProjectGrantMember) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *ProjectGrantMember) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{proj_es_model.ProjectAggregate, usr_es_model.UserAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/project_member.go b/internal/management/repository/eventsourcing/handler/project_member.go index 0a67f4a09..c4ee0409b 100644 --- a/internal/management/repository/eventsourcing/handler/project_member.go +++ b/internal/management/repository/eventsourcing/handler/project_member.go @@ -61,6 +61,10 @@ func (p *ProjectMember) ViewModel() string { return projectMemberTable } +func (p *ProjectMember) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *ProjectMember) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{proj_es_model.ProjectAggregate, usr_es_model.UserAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/project_role.go b/internal/management/repository/eventsourcing/handler/project_role.go index a067e3d43..5cb259c21 100644 --- a/internal/management/repository/eventsourcing/handler/project_role.go +++ b/internal/management/repository/eventsourcing/handler/project_role.go @@ -46,6 +46,10 @@ func (p *ProjectRole) ViewModel() string { return projectRoleTable } +func (p *ProjectRole) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *ProjectRole) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.ProjectAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/user.go b/internal/management/repository/eventsourcing/handler/user.go index 0b9d0f209..b832e7079 100644 --- a/internal/management/repository/eventsourcing/handler/user.go +++ b/internal/management/repository/eventsourcing/handler/user.go @@ -57,6 +57,10 @@ func (u *User) ViewModel() string { return userTable } +func (u *User) Subscription() *v1.Subscription { + return u.subscription +} + func (_ *User) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{es_model.UserAggregate, org_es_model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/user_external_idps.go b/internal/management/repository/eventsourcing/handler/user_external_idps.go index 0a8ae5510..0c16cffe3 100644 --- a/internal/management/repository/eventsourcing/handler/user_external_idps.go +++ b/internal/management/repository/eventsourcing/handler/user_external_idps.go @@ -61,6 +61,10 @@ func (i *ExternalIDP) ViewModel() string { return externalIDPTable } +func (i *ExternalIDP) Subscription() *v1.Subscription { + return i.subscription +} + func (_ *ExternalIDP) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{model.UserAggregate, iam_es_model.IAMAggregate, org_es_model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/user_grant.go b/internal/management/repository/eventsourcing/handler/user_grant.go index 68a9d4ddf..c64945d5a 100644 --- a/internal/management/repository/eventsourcing/handler/user_grant.go +++ b/internal/management/repository/eventsourcing/handler/user_grant.go @@ -58,6 +58,10 @@ func (u *UserGrant) ViewModel() string { return userGrantTable } +func (u *UserGrant) Subscription() *v1.Subscription { + return u.subscription +} + func (_ *UserGrant) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{grant_es_model.UserGrantAggregate, usr_es_model.UserAggregate, proj_es_model.ProjectAggregate, org_es_model.OrgAggregate} } diff --git a/internal/management/repository/eventsourcing/handler/user_membership.go b/internal/management/repository/eventsourcing/handler/user_membership.go index f28737c3c..838b4012e 100644 --- a/internal/management/repository/eventsourcing/handler/user_membership.go +++ b/internal/management/repository/eventsourcing/handler/user_membership.go @@ -56,6 +56,10 @@ func (m *UserMembership) ViewModel() string { return userMembershipTable } +func (m *UserMembership) Subscription() *v1.Subscription { + return m.subscription +} + func (_ *UserMembership) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{iam_es_model.IAMAggregate, org_es_model.OrgAggregate, proj_es_model.ProjectAggregate, model.UserAggregate} } diff --git a/internal/notification/repository/eventsourcing/handler/notification.go b/internal/notification/repository/eventsourcing/handler/notification.go index 9802bd7e2..aafd1bc3a 100644 --- a/internal/notification/repository/eventsourcing/handler/notification.go +++ b/internal/notification/repository/eventsourcing/handler/notification.go @@ -92,6 +92,10 @@ func (n *Notification) ViewModel() string { return notificationTable } +func (n *Notification) Subscription() *v1.Subscription { + return n.subscription +} + func (_ *Notification) AggregateTypes() []models.AggregateType { return []models.AggregateType{es_model.UserAggregate} } diff --git a/internal/notification/repository/eventsourcing/handler/notify_user.go b/internal/notification/repository/eventsourcing/handler/notify_user.go index 82d2ab5fd..7065526ec 100644 --- a/internal/notification/repository/eventsourcing/handler/notify_user.go +++ b/internal/notification/repository/eventsourcing/handler/notify_user.go @@ -60,6 +60,10 @@ func (p *NotifyUser) ViewModel() string { return userTable } +func (p *NotifyUser) Subscription() *v1.Subscription { + return p.subscription +} + func (_ *NotifyUser) AggregateTypes() []es_models.AggregateType { return []es_models.AggregateType{es_model.UserAggregate, org_es_model.OrgAggregate} } diff --git a/internal/ui/ui.go b/internal/ui/ui.go index a13f2b376..254a179bf 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -4,6 +4,8 @@ import ( "context" "net/http" + sentryhttp "github.com/getsentry/sentry-go/http" + http_util "github.com/caos/zitadel/internal/api/http" "github.com/caos/zitadel/internal/ui/console" "github.com/caos/zitadel/internal/ui/login" @@ -32,7 +34,8 @@ func Create(config Config) *UI { } func (u *UI) RegisterHandler(prefix string, handler http.Handler) { - http_util.RegisterHandler(u.mux, prefix, handler) + sentryHandler := sentryhttp.New(sentryhttp.Options{}) + http_util.RegisterHandler(u.mux, prefix, sentryHandler.Handle(handler)) } func (u *UI) Start(ctx context.Context) {