feat: enable default smtp config on setup (#3622)

* feat: enable default smtp config on setup

* fix tests

* fix channel order

Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
This commit is contained in:
Livio Amstutz
2022-05-13 14:13:07 +02:00
committed by GitHub
parent 5571db3e1b
commit 024eedc1b5
15 changed files with 261 additions and 159 deletions

View File

@@ -24,6 +24,7 @@ type DefaultInstance struct {
instanceSetup command.InstanceSetup
userEncryptionKey *crypto.KeyConfig
smtpEncryptionKey *crypto.KeyConfig
masterKey string
db *sql.DB
es *eventstore.Eventstore
@@ -42,12 +43,19 @@ func (mig *DefaultInstance) Execute(ctx context.Context) error {
if err = verifyKey(mig.userEncryptionKey, keyStorage); err != nil {
return err
}
userAlg, err := crypto.NewAESCrypto(mig.userEncryptionKey, keyStorage)
if err != nil {
return err
}
if err = verifyKey(mig.smtpEncryptionKey, keyStorage); err != nil {
return err
}
smtpEncryption, err := crypto.NewAESCrypto(mig.smtpEncryptionKey, keyStorage)
if err != nil {
return err
}
cmd, err := command.StartCommands(mig.es,
mig.defaults,
mig.zitadelRoles,
@@ -58,7 +66,7 @@ func (mig *DefaultInstance) Execute(ctx context.Context) error {
mig.externalPort,
nil,
nil,
nil,
smtpEncryption,
nil,
userAlg,
nil,

View File

@@ -53,6 +53,7 @@ type Steps struct {
type encryptionKeyConfig struct {
User *crypto.KeyConfig
SMTP *crypto.KeyConfig
}
func MustNewSteps(v *viper.Viper) *Steps {

View File

@@ -61,6 +61,7 @@ func Setup(config *Config, steps *Steps, masterKey string) {
steps.S3DefaultInstance.instanceSetup = config.DefaultInstance
steps.S3DefaultInstance.userEncryptionKey = config.EncryptionKeys.User
steps.S3DefaultInstance.smtpEncryptionKey = config.EncryptionKeys.SMTP
steps.S3DefaultInstance.masterKey = masterKey
steps.S3DefaultInstance.db = dbClient
steps.S3DefaultInstance.es = eventstoreClient