mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 07:54:26 +00:00
feat: http provider signing key addition (#10641)
# Which Problems Are Solved
HTTP Request to HTTP providers for Email or SMS are not signed.
# How the Problems Are Solved
Add a Signing Key to the HTTP Provider resources, which is then used to
generate a header to sign the payload.
# Additional Changes
Additional tests for query side of the SMTP provider.
# Additional Context
Closes #10067
---------
Co-authored-by: Marco A. <marco@zitadel.com>
(cherry picked from commit 8909b9a2a6)
This commit is contained in:
committed by
Livio Spring
parent
d2d94ea088
commit
1a7cd6e1af
@@ -230,6 +230,7 @@ type AddSMTPConfigHTTP struct {
|
||||
|
||||
Description string
|
||||
Endpoint string
|
||||
SigningKey string
|
||||
}
|
||||
|
||||
func (c *Commands) AddSMTPConfigHTTP(ctx context.Context, config *AddSMTPConfigHTTP) (err error) {
|
||||
@@ -248,12 +249,19 @@ func (c *Commands) AddSMTPConfigHTTP(ctx context.Context, config *AddSMTPConfigH
|
||||
return err
|
||||
}
|
||||
|
||||
code, err := c.newSigningKey(ctx, c.eventstore.Filter, c.smtpEncryption) //nolint
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.SigningKey = code.PlainCode()
|
||||
|
||||
err = c.pushAppendAndReduce(ctx, smtpConfigWriteModel, instance.NewSMTPConfigHTTPAddedEvent(
|
||||
ctx,
|
||||
InstanceAggregateFromWriteModel(&smtpConfigWriteModel.WriteModel),
|
||||
config.ID,
|
||||
config.Description,
|
||||
config.Endpoint,
|
||||
code.Crypted,
|
||||
))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -267,8 +275,10 @@ type ChangeSMTPConfigHTTP struct {
|
||||
ResourceOwner string
|
||||
ID string
|
||||
|
||||
Description string
|
||||
Endpoint string
|
||||
Description string
|
||||
Endpoint string
|
||||
ExpirationSigningKey bool
|
||||
SigningKey *string
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeSMTPConfigHTTP(ctx context.Context, config *ChangeSMTPConfigHTTP) (err error) {
|
||||
@@ -288,12 +298,23 @@ func (c *Commands) ChangeSMTPConfigHTTP(ctx context.Context, config *ChangeSMTPC
|
||||
return zerrors.ThrowNotFound(nil, "COMMAND-xIrdledqv4", "Errors.SMTPConfig.NotFound")
|
||||
}
|
||||
|
||||
var changedSigningKey *crypto.CryptoValue
|
||||
if config.ExpirationSigningKey {
|
||||
code, err := c.newSigningKey(ctx, c.eventstore.Filter, c.smtpEncryption) //nolint
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
changedSigningKey = code.Crypted
|
||||
config.SigningKey = &code.Plain
|
||||
}
|
||||
|
||||
changedEvent, hasChanged, err := smtpConfigWriteModel.NewHTTPChangedEvent(
|
||||
ctx,
|
||||
InstanceAggregateFromWriteModel(&smtpConfigWriteModel.WriteModel),
|
||||
config.ID,
|
||||
config.Description,
|
||||
config.Endpoint,
|
||||
changedSigningKey,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user