mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
new iam repo in all services
This commit is contained in:
parent
23e6cad703
commit
4b1e79604a
@ -2,15 +2,17 @@ package eventstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/iam/model"
|
||||
iam_event "github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
||||
iam_business "github.com/caos/zitadel/internal/v2/business/iam"
|
||||
)
|
||||
|
||||
type IAMRepository struct {
|
||||
IAMID string
|
||||
IAMEvents *iam_event.IAMEventstore
|
||||
IAMID string
|
||||
|
||||
IAMV2 *iam_business.Repository
|
||||
}
|
||||
|
||||
func (repo *IAMRepository) GetIAM(ctx context.Context) (*model.IAM, error) {
|
||||
return repo.IAMEvents.IAMByID(ctx, repo.IAMID)
|
||||
return repo.IAMV2.IAMByID(ctx, repo.IAMID)
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ import (
|
||||
es_org "github.com/caos/zitadel/internal/org/repository/eventsourcing"
|
||||
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"
|
||||
"github.com/caos/zitadel/internal/v2/repository/member"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@ -51,6 +55,25 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults, au
|
||||
if err != nil {
|
||||
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, policy.LabelPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LabelPolicyChangedEventType, policy.LabelPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LoginPolicyAddedEventType, policy.LoginPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LoginPolicyChangedEventType, policy.LoginPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.OrgIAMPolicyAddedEventType, policy.OrgIAMPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordAgePolicyAddedEventType, policy.PasswordAgePolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordAgePolicyChangedEventType, policy.PasswordAgePolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordComplexityPolicyAddedEventType, policy.PasswordComplexityPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordComplexityPolicyChangedEventType, policy.PasswordComplexityPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordLockoutPolicyAddedEventType, policy.PasswordLockoutPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordLockoutPolicyChangedEventType, policy.PasswordLockoutPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberAddedEventType, member.AddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberChangedEventType, member.ChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberRemovedEventType, member.RemovedEventMapper)
|
||||
|
||||
sqlClient, err := conf.View.Start()
|
||||
if err != nil {
|
||||
@ -176,8 +199,8 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults, au
|
||||
SystemDefaults: systemDefaults,
|
||||
},
|
||||
eventstore.IAMRepository{
|
||||
IAMEvents: iam,
|
||||
IAMID: systemDefaults.IamID,
|
||||
IAMID: systemDefaults.IamID,
|
||||
IAMV2: iam_business.StartRepository(&iam_business.Config{Eventstore: esV2}),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
@ -2,13 +2,17 @@ package eventstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/iam/model"
|
||||
iam_event "github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
||||
iam_business "github.com/caos/zitadel/internal/v2/business/iam"
|
||||
)
|
||||
|
||||
type IamRepo struct {
|
||||
IAMID string
|
||||
IAMEvents *iam_event.IAMEventstore
|
||||
|
||||
IAMV2 *iam_business.Repository
|
||||
}
|
||||
|
||||
func (repo *IamRepo) Health(ctx context.Context) error {
|
||||
@ -16,5 +20,5 @@ func (repo *IamRepo) Health(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (repo *IamRepo) IamByID(ctx context.Context) (*model.IAM, error) {
|
||||
return repo.IAMEvents.IAMByID(ctx, repo.IAMID)
|
||||
return repo.IAMV2.IAMByID(ctx, repo.IAMID)
|
||||
}
|
||||
|
@ -2,7 +2,11 @@ package eventsourcing
|
||||
|
||||
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/v2/repository/member"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/auth_request/repository/cache"
|
||||
@ -18,6 +22,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/id"
|
||||
es_key "github.com/caos/zitadel/internal/key/repository/eventsourcing"
|
||||
es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
||||
iam_business "github.com/caos/zitadel/internal/v2/business/iam"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@ -40,6 +45,25 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults) (*
|
||||
if err != nil {
|
||||
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, policy.LabelPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LabelPolicyChangedEventType, policy.LabelPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LoginPolicyAddedEventType, policy.LoginPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.LoginPolicyChangedEventType, policy.LoginPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.OrgIAMPolicyAddedEventType, policy.OrgIAMPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordAgePolicyAddedEventType, policy.PasswordAgePolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordAgePolicyChangedEventType, policy.PasswordAgePolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordComplexityPolicyAddedEventType, policy.PasswordComplexityPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordComplexityPolicyChangedEventType, policy.PasswordComplexityPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordLockoutPolicyAddedEventType, policy.PasswordLockoutPolicyAddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.PasswordLockoutPolicyChangedEventType, policy.PasswordLockoutPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberAddedEventType, member.AddedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberChangedEventType, member.ChangedEventMapper).
|
||||
RegisterFilterEventMapper(iam.MemberRemovedEventType, member.RemovedEventMapper)
|
||||
|
||||
sqlClient, err := conf.View.Start()
|
||||
if err != nil {
|
||||
@ -90,6 +114,7 @@ func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults) (*
|
||||
eventstore.IamRepo{
|
||||
IAMID: systemDefaults.IamID,
|
||||
IAMEvents: iam,
|
||||
IAMV2: iam_business.StartRepository(&iam_business.Config{Eventstore: esV2}),
|
||||
},
|
||||
eventstore.TokenVerifierRepo{
|
||||
//TODO: Add Token Verification Key
|
||||
|
@ -4,19 +4,13 @@ import (
|
||||
"context"
|
||||
|
||||
iam_model "github.com/caos/zitadel/internal/iam/model"
|
||||
"github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
||||
iam_business "github.com/caos/zitadel/internal/v2/business/iam"
|
||||
)
|
||||
|
||||
type IAMRepository struct {
|
||||
IAMEvents *eventsourcing.IAMEventstore
|
||||
|
||||
IAMV2 *iam_business.Repository
|
||||
}
|
||||
|
||||
func (repo *IAMRepository) IAMByID(ctx context.Context, id string) (*iam_model.IAM, error) {
|
||||
if repo.IAMV2 != nil {
|
||||
return repo.IAMV2.IAMByID(ctx, id)
|
||||
}
|
||||
return repo.IAMEvents.IAMByID(ctx, id)
|
||||
return repo.IAMV2.IAMByID(ctx, id)
|
||||
}
|
||||
|
@ -115,8 +115,7 @@ func Start(conf Config, systemDefaults sd.SystemDefaults, roles []string) (*EsRe
|
||||
UserRepo: eventstore.UserRepo{es, conf.SearchLimit, user, org, usergrant, view, systemDefaults},
|
||||
UserGrantRepo: eventstore.UserGrantRepo{conf.SearchLimit, usergrant, view},
|
||||
IAMRepository: eventstore.IAMRepository{
|
||||
IAMEvents: iam,
|
||||
IAMV2: iam_business.StartRepository(&iam_business.Config{Eventstore: esV2}),
|
||||
IAMV2: iam_business.StartRepository(&iam_business.Config{Eventstore: esV2}),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
1
internal/v2/repository/idp/config.go
Normal file
1
internal/v2/repository/idp/config.go
Normal file
@ -0,0 +1 @@
|
||||
package idp
|
Loading…
Reference in New Issue
Block a user