From d494da67be31d48e8584493546dc00054e957c39 Mon Sep 17 00:00:00 2001 From: adlerhurst Date: Mon, 30 Nov 2020 08:53:08 +0100 Subject: [PATCH] repo event mappers --- .../repository/eventsourcing/repository.go | 11 ----------- .../repository/eventsourcing/repository.go | 19 ------------------- .../repository/eventsourcing/repository.go | 19 ------------------- .../repository/eventsourcing/repository.go | 3 --- internal/v2/business/iam/repository.go | 1 + internal/v2/repository/iam/aggregate.go | 1 + 6 files changed, 2 insertions(+), 52 deletions(-) diff --git a/internal/admin/repository/eventsourcing/repository.go b/internal/admin/repository/eventsourcing/repository.go index 0747f33b3e..a8fca1165f 100644 --- a/internal/admin/repository/eventsourcing/repository.go +++ b/internal/admin/repository/eventsourcing/repository.go @@ -15,7 +15,6 @@ import ( es_org "github.com/caos/zitadel/internal/org/repository/eventsourcing" es_usr "github.com/caos/zitadel/internal/user/repository/eventsourcing" iam_business "github.com/caos/zitadel/internal/v2/business/iam" - "github.com/caos/zitadel/internal/v2/repository/iam" ) type Config struct { @@ -40,16 +39,6 @@ func Start(ctx context.Context, conf Config, systemDefaults sd.SystemDefaults, r return nil, err } esV2 := es.V2() - esV2.RegisterFilterEventMapper(iam.MemberAddedEventType, iam.MemberAddedEventMapper). - RegisterFilterEventMapper(iam.MemberChangedEventType, iam.MemberChangedEventMapper). - RegisterFilterEventMapper(iam.MemberRemovedEventType, iam.MemberRemovedEventMapper). - RegisterFilterEventMapper(iam.IDPConfigAddedEventType, iam.IDPConfigAddedEventMapper). - RegisterFilterEventMapper(iam.IDPConfigChangedEventType, iam.IDPConfigChangedEventMapper). - RegisterFilterEventMapper(iam.IDPConfigDeactivatedEventType, iam.IDPConfigDeactivatedEventMapper). - RegisterFilterEventMapper(iam.IDPConfigReactivatedEventType, iam.IDPConfigReactivatedEventMapper). - RegisterFilterEventMapper(iam.IDPConfigRemovedEventType, iam.IDPConfigRemovedEventMapper). - RegisterFilterEventMapper(iam.IDPOIDCConfigAddedEventType, iam.IDPOIDCConfigAddedEventMapper). - RegisterFilterEventMapper(iam.IDPOIDCConfigChangedEventType, iam.IDPOIDCConfigChangedEventMapper) iam, err := es_iam.StartIAM(es_iam.IAMConfig{ Eventstore: es, diff --git a/internal/auth/repository/eventsourcing/repository.go b/internal/auth/repository/eventsourcing/repository.go index f465a96777..89f2fa1569 100644 --- a/internal/auth/repository/eventsourcing/repository.go +++ b/internal/auth/repository/eventsourcing/repository.go @@ -22,7 +22,6 @@ import ( es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing" es_user "github.com/caos/zitadel/internal/user/repository/eventsourcing" iam_business "github.com/caos/zitadel/internal/v2/business/iam" - "github.com/caos/zitadel/internal/v2/repository/iam" ) type Config struct { @@ -54,24 +53,6 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults, au return nil, err } esV2 := es.V2() - esV2.RegisterFilterEventMapper(iam.SetupStartedEventType, iam.SetupStepMapper). - RegisterFilterEventMapper(iam.SetupDoneEventType, iam.SetupStepMapper). - RegisterFilterEventMapper(iam.GlobalOrgSetEventType, iam.GlobalOrgSetMapper). - RegisterFilterEventMapper(iam.ProjectSetEventType, iam.ProjectSetMapper). - RegisterFilterEventMapper(iam.LabelPolicyAddedEventType, iam.LabelPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.LabelPolicyChangedEventType, iam.LabelPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.LoginPolicyAddedEventType, iam.LoginPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.LoginPolicyChangedEventType, iam.LoginPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.OrgIAMPolicyAddedEventType, iam.OrgIAMPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordAgePolicyAddedEventType, iam.PasswordAgePolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordAgePolicyChangedEventType, iam.PasswordAgePolicyChangedEventMapper). - RegisterFilterEventMapper(iam.PasswordComplexityPolicyAddedEventType, iam.PasswordComplexityPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordComplexityPolicyChangedEventType, iam.PasswordComplexityPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.PasswordLockoutPolicyAddedEventType, iam.PasswordLockoutPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordLockoutPolicyChangedEventType, iam.PasswordLockoutPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.MemberAddedEventType, iam.MemberAddedEventMapper). - RegisterFilterEventMapper(iam.MemberChangedEventType, iam.MemberChangedEventMapper). - RegisterFilterEventMapper(iam.MemberRemovedEventType, iam.MemberRemovedEventMapper) sqlClient, err := conf.View.Start() if err != nil { diff --git a/internal/authz/repository/eventsourcing/repository.go b/internal/authz/repository/eventsourcing/repository.go index 06574aae6a..b27d1b1637 100644 --- a/internal/authz/repository/eventsourcing/repository.go +++ b/internal/authz/repository/eventsourcing/repository.go @@ -4,7 +4,6 @@ import ( "context" es_user "github.com/caos/zitadel/internal/user/repository/eventsourcing" - "github.com/caos/zitadel/internal/v2/repository/iam" "github.com/caos/zitadel/internal/api/authz" "github.com/caos/zitadel/internal/auth_request/repository/cache" @@ -44,24 +43,6 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults) (* return nil, err } esV2 := es.V2() - esV2.RegisterFilterEventMapper(iam.SetupStartedEventType, iam.SetupStepMapper). - RegisterFilterEventMapper(iam.SetupDoneEventType, iam.SetupStepMapper). - RegisterFilterEventMapper(iam.GlobalOrgSetEventType, iam.GlobalOrgSetMapper). - RegisterFilterEventMapper(iam.ProjectSetEventType, iam.ProjectSetMapper). - RegisterFilterEventMapper(iam.LabelPolicyAddedEventType, iam.LabelPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.LabelPolicyChangedEventType, iam.LabelPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.LoginPolicyAddedEventType, iam.LoginPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.LoginPolicyChangedEventType, iam.LoginPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.OrgIAMPolicyAddedEventType, iam.OrgIAMPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordAgePolicyAddedEventType, iam.PasswordAgePolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordAgePolicyChangedEventType, iam.PasswordAgePolicyChangedEventMapper). - RegisterFilterEventMapper(iam.PasswordComplexityPolicyAddedEventType, iam.PasswordComplexityPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordComplexityPolicyChangedEventType, iam.PasswordComplexityPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.PasswordLockoutPolicyAddedEventType, iam.PasswordLockoutPolicyAddedEventMapper). - RegisterFilterEventMapper(iam.PasswordLockoutPolicyChangedEventType, iam.PasswordLockoutPolicyChangedEventMapper). - RegisterFilterEventMapper(iam.MemberAddedEventType, iam.MemberAddedEventMapper). - RegisterFilterEventMapper(iam.MemberChangedEventType, iam.MemberChangedEventMapper). - RegisterFilterEventMapper(iam.MemberRemovedEventType, iam.MemberRemovedEventMapper) sqlClient, err := conf.View.Start() if err != nil { diff --git a/internal/management/repository/eventsourcing/repository.go b/internal/management/repository/eventsourcing/repository.go index 9a22da184e..50ac45d7c1 100644 --- a/internal/management/repository/eventsourcing/repository.go +++ b/internal/management/repository/eventsourcing/repository.go @@ -18,7 +18,6 @@ import ( es_usr "github.com/caos/zitadel/internal/user/repository/eventsourcing" es_grant "github.com/caos/zitadel/internal/usergrant/repository/eventsourcing" iam_business "github.com/caos/zitadel/internal/v2/business/iam" - iam_repo "github.com/caos/zitadel/internal/v2/repository/iam" ) type Config struct { @@ -45,8 +44,6 @@ func Start(conf Config, systemDefaults sd.SystemDefaults, roles []string) (*EsRe return nil, err } esV2 := es.V2() - //TODO: should it be iam repo or iam business? - iam_repo.RegisterEventMappers(esV2) sqlClient, err := conf.View.Start() if err != nil { diff --git a/internal/v2/business/iam/repository.go b/internal/v2/business/iam/repository.go index 8641ddd67d..b1f8ab9dc9 100644 --- a/internal/v2/business/iam/repository.go +++ b/internal/v2/business/iam/repository.go @@ -28,6 +28,7 @@ func StartRepository(config *Config) (repo *Repository, err error) { eventstore: config.Eventstore, idGenerator: id.SonyFlakeGenerator, } + iam_repo.RegisterEventMappers(repo.eventstore) repo.secretCrypto, err = crypto.NewAESCrypto(config.SystemDefaults.IDPConfigVerificationKey) if err != nil { diff --git a/internal/v2/repository/iam/aggregate.go b/internal/v2/repository/iam/aggregate.go index 63105f3c27..1380e98b8e 100644 --- a/internal/v2/repository/iam/aggregate.go +++ b/internal/v2/repository/iam/aggregate.go @@ -107,6 +107,7 @@ func (a *Aggregate) PushIDPConfigChanged( configType idp.ConfigType, stylingType idp.StylingType, ) *Aggregate { + event, err := NewIDPConfigChangedEvent(ctx, current, configID, name, configType, stylingType) if err != nil { return a