repo event mappers

This commit is contained in:
adlerhurst 2020-11-30 08:53:08 +01:00
parent 968f766a8f
commit d494da67be
6 changed files with 2 additions and 52 deletions

View File

@ -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,

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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