mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:07:31 +00:00
add system config (#71)
This commit is contained in:
12
internal/config/systemdefaults/system_defaults.go
Normal file
12
internal/config/systemdefaults/system_defaults.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package systemdefaults
|
||||
|
||||
import "github.com/caos/zitadel/internal/crypto"
|
||||
|
||||
type SystemDefaults struct {
|
||||
SecretGenerator SecretGenerator
|
||||
}
|
||||
|
||||
type SecretGenerator struct {
|
||||
PasswordSaltCost int
|
||||
ClientSecretGenerator crypto.GeneratorConfig
|
||||
}
|
@@ -2,8 +2,8 @@ package eventsourcing
|
||||
|
||||
import (
|
||||
"context"
|
||||
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
es_int "github.com/caos/zitadel/internal/eventstore"
|
||||
es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
||||
)
|
||||
@@ -12,8 +12,6 @@ type Config struct {
|
||||
Eventstore es_int.Config
|
||||
//View view.ViewConfig
|
||||
//Spooler spooler.SpoolerConfig
|
||||
PasswordSaltCost int
|
||||
ClientSecretGenerator crypto.GeneratorConfig
|
||||
}
|
||||
|
||||
type EsRepository struct {
|
||||
@@ -21,7 +19,7 @@ type EsRepository struct {
|
||||
ProjectRepo
|
||||
}
|
||||
|
||||
func Start(conf Config) (*EsRepository, error) {
|
||||
func Start(conf Config, systemDefaults sd.SystemDefaults) (*EsRepository, error) {
|
||||
es, err := es_int.Start(conf.Eventstore)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -38,11 +36,9 @@ func Start(conf Config) (*EsRepository, error) {
|
||||
//spool := spooler.StartSpooler(conf.Spooler)
|
||||
|
||||
project, err := es_proj.StartProject(es_proj.ProjectConfig{
|
||||
Eventstore: es,
|
||||
Cache: conf.Eventstore.Cache,
|
||||
PasswordSaltCost: conf.PasswordSaltCost,
|
||||
ClientSecretGenerator: conf.ClientSecretGenerator,
|
||||
})
|
||||
Eventstore: es,
|
||||
Cache: conf.Eventstore.Cache,
|
||||
}, systemDefaults)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package eventsourcing
|
||||
|
||||
import (
|
||||
"context"
|
||||
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||||
"strconv"
|
||||
|
||||
@@ -24,18 +25,16 @@ type ProjectEventstore struct {
|
||||
|
||||
type ProjectConfig struct {
|
||||
es_int.Eventstore
|
||||
Cache *config.CacheConfig
|
||||
PasswordSaltCost int
|
||||
ClientSecretGenerator crypto.GeneratorConfig
|
||||
Cache *config.CacheConfig
|
||||
}
|
||||
|
||||
func StartProject(conf ProjectConfig) (*ProjectEventstore, error) {
|
||||
func StartProject(conf ProjectConfig, systemDefaults sd.SystemDefaults) (*ProjectEventstore, error) {
|
||||
projectCache, err := StartCache(conf.Cache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
passwordAlg := crypto.NewBCrypt(conf.PasswordSaltCost)
|
||||
pwGenerator := crypto.NewHashGenerator(conf.ClientSecretGenerator, passwordAlg)
|
||||
passwordAlg := crypto.NewBCrypt(systemDefaults.SecretGenerator.PasswordSaltCost)
|
||||
pwGenerator := crypto.NewHashGenerator(systemDefaults.SecretGenerator.ClientSecretGenerator, passwordAlg)
|
||||
idGenerator := sonyflake.NewSonyflake(sonyflake.Settings{})
|
||||
return &ProjectEventstore{
|
||||
Eventstore: conf.Eventstore,
|
||||
|
Reference in New Issue
Block a user