mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
7a6ca24625
* check uniqueness on create and register user * change user email, reserve release unique email * usergrant unique aggregate * usergrant uniqueness * validate UserGrant * fix tests * domain is set on username in all orgs * domain in admin * org domain sql * zitadel domain org name * org domains * org iam policy * default org iam policy * SETUP * load login names * login by login name * login name * fix: merge master * fix: merge master * Update internal/user/repository/eventsourcing/user.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: fix unique domains * fix: rename env variable Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
110 lines
3.4 KiB
Go
110 lines
3.4 KiB
Go
package eventsourcing
|
|
|
|
import (
|
|
"context"
|
|
|
|
es_iam "github.com/caos/zitadel/internal/iam/repository/eventsourcing"
|
|
|
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
|
"github.com/caos/zitadel/internal/config/types"
|
|
es_int "github.com/caos/zitadel/internal/eventstore"
|
|
es_spol "github.com/caos/zitadel/internal/eventstore/spooler"
|
|
"github.com/caos/zitadel/internal/management/repository/eventsourcing/eventstore"
|
|
"github.com/caos/zitadel/internal/management/repository/eventsourcing/handler"
|
|
"github.com/caos/zitadel/internal/management/repository/eventsourcing/spooler"
|
|
mgmt_view "github.com/caos/zitadel/internal/management/repository/eventsourcing/view"
|
|
es_org "github.com/caos/zitadel/internal/org/repository/eventsourcing"
|
|
es_pol "github.com/caos/zitadel/internal/policy/repository/eventsourcing"
|
|
es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
|
es_usr "github.com/caos/zitadel/internal/user/repository/eventsourcing"
|
|
es_grant "github.com/caos/zitadel/internal/usergrant/repository/eventsourcing"
|
|
)
|
|
|
|
type Config struct {
|
|
SearchLimit uint64
|
|
Domain string
|
|
Eventstore es_int.Config
|
|
View types.SQL
|
|
Spooler spooler.SpoolerConfig
|
|
}
|
|
|
|
type EsRepository struct {
|
|
spooler *es_spol.Spooler
|
|
eventstore.OrgRepository
|
|
eventstore.ProjectRepo
|
|
eventstore.UserRepo
|
|
eventstore.UserGrantRepo
|
|
eventstore.PolicyRepo
|
|
eventstore.IamRepository
|
|
}
|
|
|
|
func Start(conf Config, systemDefaults sd.SystemDefaults, roles []string) (*EsRepository, error) {
|
|
es, err := es_int.Start(conf.Eventstore)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sqlClient, err := conf.View.Start()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
view, err := mgmt_view.StartView(sqlClient)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
project, err := es_proj.StartProject(es_proj.ProjectConfig{
|
|
Eventstore: es,
|
|
Cache: conf.Eventstore.Cache,
|
|
}, systemDefaults)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
policy, err := es_pol.StartPolicy(es_pol.PolicyConfig{
|
|
Eventstore: es,
|
|
Cache: conf.Eventstore.Cache,
|
|
}, systemDefaults)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
user, err := es_usr.StartUser(es_usr.UserConfig{
|
|
Eventstore: es,
|
|
Cache: conf.Eventstore.Cache,
|
|
}, systemDefaults)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
usergrant, err := es_grant.StartUserGrant(es_grant.UserGrantConfig{
|
|
Eventstore: es,
|
|
Cache: conf.Eventstore.Cache,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
org := es_org.StartOrg(es_org.OrgConfig{Eventstore: es, IAMDomain: conf.Domain}, systemDefaults)
|
|
|
|
iam, err := es_iam.StartIam(es_iam.IamConfig{
|
|
Eventstore: es,
|
|
Cache: conf.Eventstore.Cache,
|
|
}, systemDefaults)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
eventstoreRepos := handler.EventstoreRepos{ProjectEvents: project, UserEvents: user, OrgEvents: org}
|
|
spool := spooler.StartSpooler(conf.Spooler, es, view, sqlClient, eventstoreRepos)
|
|
|
|
return &EsRepository{
|
|
spooler: spool,
|
|
OrgRepository: eventstore.OrgRepository{conf.SearchLimit, org, view, roles},
|
|
ProjectRepo: eventstore.ProjectRepo{conf.SearchLimit, project, view, roles},
|
|
UserRepo: eventstore.UserRepo{conf.SearchLimit, user, policy, org, view},
|
|
UserGrantRepo: eventstore.UserGrantRepo{conf.SearchLimit, usergrant, view},
|
|
PolicyRepo: eventstore.PolicyRepo{policy},
|
|
IamRepository: eventstore.IamRepository{iam},
|
|
}, nil
|
|
}
|
|
|
|
func (repo *EsRepository) Health() error {
|
|
return repo.ProjectEvents.Health(context.Background())
|
|
}
|