feat: run on a single port (#3163)

* start v2

* start

* run

* some cleanup

* remove v2 pkg again

* simplify

* webauthn

* remove unused config

* fix login path in Dockerfile

* fix asset_generator.go

* health handler

* fix grpc web

* refactor

* merge

* build new main.go

* run new main.go

* update logging pkg

* fix error msg

* update logging

* cleanup

* cleanup

* go mod tidy

* change localDevMode

* fix customEndpoints

* update logging

* comments

* change local flag to external configs

* fix location generated go code

* fix

Co-authored-by: fforootd <florian@caos.ch>
This commit is contained in:
Livio Amstutz
2022-02-14 17:22:30 +01:00
committed by GitHub
parent 2f3a482ade
commit 389eb4a27a
306 changed files with 1708 additions and 1567 deletions

View File

@@ -5,21 +5,20 @@ import (
"time"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/internal/command"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/config/types"
"github.com/caos/zitadel/internal/crypto"
v1 "github.com/caos/zitadel/internal/eventstore/v1"
queryv1 "github.com/caos/zitadel/internal/eventstore/v1/query"
"github.com/caos/zitadel/internal/notification/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/query"
)
type Configs map[string]*Config
type Config struct {
MinimumCycleDuration types.Duration
MinimumCycleDuration time.Duration
}
type handler struct {
@@ -35,11 +34,10 @@ func (h *handler) Eventstore() v1.Eventstore {
return h.es
}
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es v1.Eventstore, command *command.Commands, queries *query.Queries, systemDefaults sd.SystemDefaults, dir http.FileSystem, apiDomain string) []queryv1.Handler {
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es v1.Eventstore, command *command.Commands, queries *query.Queries, systemDefaults sd.SystemDefaults, dir http.FileSystem, assetsPrefix string) []queryv1.Handler {
aesCrypto, err := crypto.NewAESCrypto(systemDefaults.UserVerificationKey)
if err != nil {
logging.Log("HANDL-s90ew").WithError(err).Debug("error create new aes crypto")
}
logging.OnError(err).Fatal("error create new aes crypto")
return []queryv1.Handler{
newNotifyUser(
handler{view, bulkLimit, configs.cycleDuration("User"), errorCount, es},
@@ -53,7 +51,7 @@ func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es
systemDefaults,
aesCrypto,
dir,
apiDomain,
assetsPrefix,
),
}
}
@@ -63,7 +61,7 @@ func (configs Configs) cycleDuration(viewModel string) time.Duration {
if !ok {
return 1 * time.Minute
}
return c.MinimumCycleDuration.Duration
return c.MinimumCycleDuration
}
func (h *handler) MinimumCycleDuration() time.Duration {

View File

@@ -7,6 +7,7 @@ import (
"time"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/command"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
@@ -38,7 +39,7 @@ type Notification struct {
AesCrypto crypto.EncryptionAlgorithm
statikDir http.FileSystem
subscription *v1.Subscription
apiDomain string
assetsPrefix string
queries *query.Queries
}
@@ -49,7 +50,7 @@ func newNotification(
defaults sd.SystemDefaults,
aesCrypto crypto.EncryptionAlgorithm,
statikDir http.FileSystem,
apiDomain string,
assetsPrefix string,
) *Notification {
h := &Notification{
handler: handler,
@@ -57,7 +58,7 @@ func newNotification(
systemDefaults: defaults,
statikDir: statikDir,
AesCrypto: aesCrypto,
apiDomain: apiDomain,
assetsPrefix: assetsPrefix,
queries: query,
}
@@ -160,7 +161,7 @@ func (n *Notification) handleInitUserCode(event *models.Event) (err error) {
return err
}
err = types.SendUserInitCode(string(template.Template), translator, user, initCode, n.systemDefaults, n.AesCrypto, colors, n.apiDomain)
err = types.SendUserInitCode(string(template.Template), translator, user, initCode, n.systemDefaults, n.AesCrypto, colors, n.assetsPrefix)
if err != nil {
return err
}
@@ -198,7 +199,7 @@ func (n *Notification) handlePasswordCode(event *models.Event) (err error) {
if err != nil {
return err
}
err = types.SendPasswordCode(string(template.Template), translator, user, pwCode, n.systemDefaults, n.AesCrypto, colors, n.apiDomain)
err = types.SendPasswordCode(string(template.Template), translator, user, pwCode, n.systemDefaults, n.AesCrypto, colors, n.assetsPrefix)
if err != nil {
return err
}
@@ -237,7 +238,7 @@ func (n *Notification) handleEmailVerificationCode(event *models.Event) (err err
return err
}
err = types.SendEmailVerificationCode(string(template.Template), translator, user, emailCode, n.systemDefaults, n.AesCrypto, colors, n.apiDomain)
err = types.SendEmailVerificationCode(string(template.Template), translator, user, emailCode, n.systemDefaults, n.AesCrypto, colors, n.assetsPrefix)
if err != nil {
return err
}
@@ -302,7 +303,7 @@ func (n *Notification) handleDomainClaimed(event *models.Event) (err error) {
if err != nil {
return err
}
err = types.SendDomainClaimed(string(template.Template), translator, user, data["userName"], n.systemDefaults, colors, n.apiDomain)
err = types.SendDomainClaimed(string(template.Template), translator, user, data["userName"], n.systemDefaults, colors, n.assetsPrefix)
if err != nil {
return err
}
@@ -348,7 +349,7 @@ func (n *Notification) handlePasswordlessRegistrationLink(event *models.Event) (
if err != nil {
return err
}
err = types.SendPasswordlessRegistrationLink(string(template.Template), translator, user, addedEvent, n.systemDefaults, n.AesCrypto, colors, n.apiDomain)
err = types.SendPasswordlessRegistrationLink(string(template.Template), translator, user, addedEvent, n.systemDefaults, n.AesCrypto, colors, n.assetsPrefix)
if err != nil {
return err
}