mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-06 09:16:49 +00:00
add system config (#71)
This commit is contained in:
parent
8464cfa4fe
commit
ff11cdba40
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
|
|
||||||
"github.com/caos/logging"
|
"github.com/caos/logging"
|
||||||
|
|
||||||
@ -23,9 +24,10 @@ type Config struct {
|
|||||||
Admin admin.Config
|
Admin admin.Config
|
||||||
Console console.Config
|
Console console.Config
|
||||||
|
|
||||||
Log logging.Config
|
Log logging.Config
|
||||||
Tracing tracing.TracingConfig
|
Tracing tracing.TracingConfig
|
||||||
AuthZ authz.Config
|
AuthZ authz.Config
|
||||||
|
SystemDefaults sd.SystemDefaults
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -44,10 +46,10 @@ func main() {
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
if *managementEnabled {
|
if *managementEnabled {
|
||||||
management.Start(ctx, conf.Mgmt, conf.AuthZ)
|
management.Start(ctx, conf.Mgmt, conf.AuthZ, conf.SystemDefaults)
|
||||||
}
|
}
|
||||||
if *authEnabled {
|
if *authEnabled {
|
||||||
auth.Start(ctx, conf.Auth, conf.AuthZ)
|
auth.Start(ctx, conf.Auth, conf.AuthZ, conf.SystemDefaults)
|
||||||
}
|
}
|
||||||
if *loginEnabled {
|
if *loginEnabled {
|
||||||
err = login.Start(ctx, conf.Login)
|
err = login.Start(ctx, conf.Login)
|
||||||
|
@ -31,13 +31,6 @@ Mgmt:
|
|||||||
Type: 'fastcache'
|
Type: 'fastcache'
|
||||||
Config:
|
Config:
|
||||||
MaxCacheSizeInByte: 10485760 #10mb
|
MaxCacheSizeInByte: 10485760 #10mb
|
||||||
PasswordSaltCost: 14
|
|
||||||
ClientSecretGenerator:
|
|
||||||
Length: 64
|
|
||||||
IncludeLowerLetters: true
|
|
||||||
IncludeUpperLetters: true
|
|
||||||
IncludeDigits: true
|
|
||||||
IncludeSymbols: true
|
|
||||||
|
|
||||||
|
|
||||||
Auth:
|
Auth:
|
||||||
|
8
cmd/zitadel/system-defaults.yaml
Normal file
8
cmd/zitadel/system-defaults.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
SecretGenerators:
|
||||||
|
PasswordSaltCost: 14
|
||||||
|
ClientSecretGenerator:
|
||||||
|
Length: 64
|
||||||
|
IncludeLowerLetters: true
|
||||||
|
IncludeUpperLetters: true
|
||||||
|
IncludeDigits: true
|
||||||
|
IncludeSymbols: true
|
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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
|
|
||||||
"github.com/caos/zitadel/internal/crypto"
|
|
||||||
es_int "github.com/caos/zitadel/internal/eventstore"
|
es_int "github.com/caos/zitadel/internal/eventstore"
|
||||||
es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
es_proj "github.com/caos/zitadel/internal/project/repository/eventsourcing"
|
||||||
)
|
)
|
||||||
@ -12,8 +12,6 @@ type Config struct {
|
|||||||
Eventstore es_int.Config
|
Eventstore es_int.Config
|
||||||
//View view.ViewConfig
|
//View view.ViewConfig
|
||||||
//Spooler spooler.SpoolerConfig
|
//Spooler spooler.SpoolerConfig
|
||||||
PasswordSaltCost int
|
|
||||||
ClientSecretGenerator crypto.GeneratorConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type EsRepository struct {
|
type EsRepository struct {
|
||||||
@ -21,7 +19,7 @@ type EsRepository struct {
|
|||||||
ProjectRepo
|
ProjectRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(conf Config) (*EsRepository, error) {
|
func Start(conf Config, systemDefaults sd.SystemDefaults) (*EsRepository, error) {
|
||||||
es, err := es_int.Start(conf.Eventstore)
|
es, err := es_int.Start(conf.Eventstore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -38,11 +36,9 @@ func Start(conf Config) (*EsRepository, error) {
|
|||||||
//spool := spooler.StartSpooler(conf.Spooler)
|
//spool := spooler.StartSpooler(conf.Spooler)
|
||||||
|
|
||||||
project, err := es_proj.StartProject(es_proj.ProjectConfig{
|
project, err := es_proj.StartProject(es_proj.ProjectConfig{
|
||||||
Eventstore: es,
|
Eventstore: es,
|
||||||
Cache: conf.Eventstore.Cache,
|
Cache: conf.Eventstore.Cache,
|
||||||
PasswordSaltCost: conf.PasswordSaltCost,
|
}, systemDefaults)
|
||||||
ClientSecretGenerator: conf.ClientSecretGenerator,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package eventsourcing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
"github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -24,18 +25,16 @@ type ProjectEventstore struct {
|
|||||||
|
|
||||||
type ProjectConfig struct {
|
type ProjectConfig struct {
|
||||||
es_int.Eventstore
|
es_int.Eventstore
|
||||||
Cache *config.CacheConfig
|
Cache *config.CacheConfig
|
||||||
PasswordSaltCost int
|
|
||||||
ClientSecretGenerator crypto.GeneratorConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartProject(conf ProjectConfig) (*ProjectEventstore, error) {
|
func StartProject(conf ProjectConfig, systemDefaults sd.SystemDefaults) (*ProjectEventstore, error) {
|
||||||
projectCache, err := StartCache(conf.Cache)
|
projectCache, err := StartCache(conf.Cache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
passwordAlg := crypto.NewBCrypt(conf.PasswordSaltCost)
|
passwordAlg := crypto.NewBCrypt(systemDefaults.SecretGenerator.PasswordSaltCost)
|
||||||
pwGenerator := crypto.NewHashGenerator(conf.ClientSecretGenerator, passwordAlg)
|
pwGenerator := crypto.NewHashGenerator(systemDefaults.SecretGenerator.ClientSecretGenerator, passwordAlg)
|
||||||
idGenerator := sonyflake.NewSonyflake(sonyflake.Settings{})
|
idGenerator := sonyflake.NewSonyflake(sonyflake.Settings{})
|
||||||
return &ProjectEventstore{
|
return &ProjectEventstore{
|
||||||
Eventstore: conf.Eventstore,
|
Eventstore: conf.Eventstore,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/caos/zitadel/internal/api/auth"
|
"github.com/caos/zitadel/internal/api/auth"
|
||||||
app "github.com/caos/zitadel/internal/auth"
|
app "github.com/caos/zitadel/internal/auth"
|
||||||
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
"github.com/caos/zitadel/pkg/auth/api"
|
"github.com/caos/zitadel/pkg/auth/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,6 +13,6 @@ type Config struct {
|
|||||||
API api.Config
|
API api.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config Config, authZ auth.Config) {
|
func Start(ctx context.Context, config Config, authZ auth.Config, systemDefaults sd.SystemDefaults) {
|
||||||
api.Start(ctx, config.API)
|
api.Start(ctx, config.API)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/caos/logging"
|
"github.com/caos/logging"
|
||||||
"github.com/caos/zitadel/internal/api/auth"
|
"github.com/caos/zitadel/internal/api/auth"
|
||||||
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
||||||
"github.com/caos/zitadel/internal/management/repository/eventsourcing"
|
"github.com/caos/zitadel/internal/management/repository/eventsourcing"
|
||||||
"github.com/caos/zitadel/pkg/management/api"
|
"github.com/caos/zitadel/pkg/management/api"
|
||||||
)
|
)
|
||||||
@ -13,8 +14,8 @@ type Config struct {
|
|||||||
API api.Config
|
API api.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx context.Context, config Config, authZ auth.Config) {
|
func Start(ctx context.Context, config Config, authZ auth.Config, systemDefaults sd.SystemDefaults) {
|
||||||
repo, err := eventsourcing.Start(config.Repository)
|
repo, err := eventsourcing.Start(config.Repository, systemDefaults)
|
||||||
logging.Log("MAIN-9uBxp").OnError(err).Panic("unable to start app")
|
logging.Log("MAIN-9uBxp").OnError(err).Panic("unable to start app")
|
||||||
|
|
||||||
api.Start(ctx, config.API, authZ, repo)
|
api.Start(ctx, config.API, authZ, repo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user