From 0e472a347f98793764e2c0d7186bcf3151fe83b4 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 6 Jul 2021 13:36:35 +0200 Subject: [PATCH] fix: add sentry in ui, http and projection handlers (#1977) * fix: add sentry in ui, http and projection handlers * fix test --- .../eventsourcing/handler/custom_text.go | 4 ++++ .../repository/eventsourcing/handler/features.go | 4 ++++ .../eventsourcing/handler/iam_member.go | 5 ++++- .../eventsourcing/handler/idp_config.go | 4 ++++ .../eventsourcing/handler/idp_providers.go | 4 ++++ .../eventsourcing/handler/label_policy.go | 4 ++++ .../eventsourcing/handler/login_policy.go | 8 +++++++- .../eventsourcing/handler/mail_template.go | 14 +++++++++----- .../eventsourcing/handler/message_text.go | 5 +++++ .../admin/repository/eventsourcing/handler/org.go | 4 ++++ .../eventsourcing/handler/org_iam_policy.go | 5 +++++ .../eventsourcing/handler/password_age_policy.go | 5 +++++ .../handler/password_complexity_policy.go | 5 +++++ .../handler/password_lockout_policy.go | 4 ++++ .../eventsourcing/handler/privacy_policy.go | 4 ++++ .../repository/eventsourcing/handler/styling.go | 4 ++++ .../repository/eventsourcing/handler/user.go | 4 ++++ .../eventsourcing/handler/user_external_idps.go | 4 ++++ internal/api/api.go | 4 +++- .../eventsourcing/handler/application.go | 4 ++++ .../eventsourcing/handler/authn_keys.go | 4 ++++ .../eventsourcing/handler/custom_text.go | 4 ++++ .../repository/eventsourcing/handler/features.go | 4 ++++ .../eventsourcing/handler/idp_config.go | 4 ++++ .../eventsourcing/handler/idp_providers.go | 4 ++++ .../auth/repository/eventsourcing/handler/key.go | 4 ++++ .../eventsourcing/handler/label_policy.go | 4 ++++ .../eventsourcing/handler/login_policy.go | 4 ++++ .../auth/repository/eventsourcing/handler/org.go | 4 ++++ .../eventsourcing/handler/org_iam_policy.go | 4 ++++ .../handler/password_complexity_policy.go | 4 ++++ .../eventsourcing/handler/privacy_policy.go | 4 ++++ .../eventsourcing/handler/project_role.go | 4 ++++ .../eventsourcing/handler/refresh_token.go | 4 ++++ .../repository/eventsourcing/handler/token.go | 4 ++++ .../auth/repository/eventsourcing/handler/user.go | 3 +++ .../eventsourcing/handler/user_external_idps.go | 4 ++++ .../eventsourcing/handler/user_grant.go | 4 ++++ .../eventsourcing/handler/user_membership.go | 4 ++++ .../eventsourcing/handler/user_session.go | 4 ++++ .../eventsourcing/handler/application.go | 4 ++++ .../repository/eventsourcing/handler/features.go | 4 ++++ .../authz/repository/eventsourcing/handler/org.go | 4 ++++ .../eventsourcing/handler/user_grant.go | 4 ++++ .../eventsourcing/handler/user_membership.go | 4 ++++ internal/eventstore/v1/query/handler.go | 15 ++++++++++++++- internal/eventstore/v1/spooler/spooler.go | 12 +++++++++++- internal/eventstore/v1/spooler/spooler_test.go | 4 ++++ .../eventsourcing/handler/application.go | 4 ++++ .../eventsourcing/handler/authn_keys.go | 4 ++++ .../eventsourcing/handler/custom_text.go | 4 ++++ .../repository/eventsourcing/handler/features.go | 4 ++++ .../eventsourcing/handler/idp_config.go | 4 ++++ .../eventsourcing/handler/idp_providers.go | 4 ++++ .../eventsourcing/handler/label_policy.go | 4 ++++ .../eventsourcing/handler/login_policy.go | 4 ++++ .../eventsourcing/handler/mail_template.go | 4 ++++ .../eventsourcing/handler/message_text.go | 4 ++++ .../repository/eventsourcing/handler/org.go | 4 ++++ .../eventsourcing/handler/org_domain.go | 4 ++++ .../eventsourcing/handler/org_iam_policy.go | 4 ++++ .../eventsourcing/handler/org_member.go | 4 ++++ .../eventsourcing/handler/password_age_policy.go | 4 ++++ .../handler/password_complexity_policy.go | 4 ++++ .../handler/password_lockout_policy.go | 4 ++++ .../eventsourcing/handler/privacy_policy.go | 4 ++++ .../repository/eventsourcing/handler/project.go | 4 ++++ .../eventsourcing/handler/project_grant.go | 4 ++++ .../eventsourcing/handler/project_grant_member.go | 4 ++++ .../eventsourcing/handler/project_member.go | 4 ++++ .../eventsourcing/handler/project_role.go | 4 ++++ .../repository/eventsourcing/handler/user.go | 4 ++++ .../eventsourcing/handler/user_external_idps.go | 4 ++++ .../eventsourcing/handler/user_grant.go | 4 ++++ .../eventsourcing/handler/user_membership.go | 4 ++++ .../eventsourcing/handler/notification.go | 4 ++++ .../eventsourcing/handler/notify_user.go | 4 ++++ internal/ui/ui.go | 5 ++++- 78 files changed, 339 insertions(+), 11 deletions(-) diff --git a/internal/admin/repository/eventsourcing/handler/custom_text.go b/internal/admin/repository/eventsourcing/handler/custom_text.go index 4d6ceef2d9..8a2d8697ab 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 da1671ddb7..408864e48c 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 10ccb7fd54..0dcce47b6d 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 a45e99f649..d815ac5a24 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 572119f67c..2cfd435a38 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 b5c6a4abae..c54c39be98 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 7eb91ba2d9..0c1b818be8 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 6117449f43..8af4968d32 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 8bdb17ea1b..05083427e3 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 42e7414886..be3682a966 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 d1beeab5f9..5b32c8f6b1 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 d1a0be0d12..66065cc2ea 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 221325ead0..51e67d232b 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 d04a507724..39aefbb0b6 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 9620de9f41..0b842eb7ed 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 cee90d7254..f449098d21 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 d0731e9545..4427c3e899 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 02d9e1ba2f..0cb37fa07e 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 ef12ff5f63..e7b5225e9c 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 3b56bc67a5..7ef1d6fbba 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 f7a2fdf69a..6e485ac720 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 f17a2e6ad5..1cc457ddfc 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 b025649528..5775f8845d 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 225d1b208c..20798e26ee 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 3b104ab4f6..442e03b8ab 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 4c72a17334..372533c0cb 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 2759e609da..a00ac4a9e7 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 3e577b7f4d..34f2aa9765 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 e330aa0d5c..70990ef9ee 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 6fa4a729da..8357b55892 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 25ed11aae1..f50b16e49c 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 f79a036dd9..4240f1c1f7 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 6c7f16c13f..a63ff34363 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 e88a2b632d..6b2cd19788 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 c1b05e0faa..596cd56e48 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 212c660783..d3e88e0422 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 b3c4c17967..a5b71dd11c 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 4296a95203..96fb693a08 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 d867b3a97b..ca3f27adbf 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 63f83133b6..4b9cede173 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 ceb818caf7..c707985067 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 c558acd388..86b2d0bdc9 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 62bc9ec053..aca287fd40 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 e392dcfb35..3c3fea47eb 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 2c67623ea3..c6dbf9dc7e 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 a04a585289..e9f5600fca 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 b858b11221..1b632d6d58 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 eb475d93e2..6b327fa7bd 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 5ada9f92bf..c7be7ecffe 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 b5e7e82daa..82e6edb60f 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 9409302a68..3e8f2c2eb9 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 5f4f556e64..44abb12df0 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 b4a953dbc4..a900e56b25 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 71cfb70e02..00ecfb3ff4 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 0c87c50789..d7b0fb3da7 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 f78a24780a..ca5a68845d 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 042410e71b..a165766f4f 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 182de31276..4382ccbd6a 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 2c73b4e26c..0f2be8e16c 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 0f53dbeeca..11e4355dba 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 e194e0dfa1..1c9b5d13a5 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 d46c84d2e7..2b140a25c9 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 e798cfbbd1..857d83078f 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 9366ea1a38..cb7575f600 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 a5ed4c7cd7..bd9c0f0f11 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 39a8fd6bdb..382b74d788 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 a5355af288..22fb60b28b 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 7427937768..3b0366a7d1 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 a82eaf3c6c..261c1239a1 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 0a67f4a095..c4ee0409bc 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 a067e3d43a..5cb259c213 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 0b9d0f2094..b832e70790 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 0a8ae55105..0c16cffe3b 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 68a9d4ddfa..c64945d5aa 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 f28737c3cb..838b4012e8 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 9802bd7e2c..aafd1bc3a1 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 82d2ab5fdf..7065526ec9 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 a13f2b3762..254a179bfe 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) {