mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-15 02:15:14 +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. <[email protected]>
This commit is contained in:
@@ -157,6 +157,7 @@ type AddSMSHTTP struct {
|
||||
|
||||
Description string
|
||||
Endpoint string
|
||||
SigningKey string
|
||||
}
|
||||
|
||||
func (c *Commands) AddSMSConfigHTTP(ctx context.Context, config *AddSMSHTTP) (err error) {
|
||||
@@ -174,6 +175,12 @@ func (c *Commands) AddSMSConfigHTTP(ctx context.Context, config *AddSMSHTTP) (er
|
||||
return err
|
||||
}
|
||||
|
||||
code, err := c.newSigningKey(ctx, c.eventstore.Filter, c.smsEncryption) //nolint
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.SigningKey = code.PlainCode()
|
||||
|
||||
err = c.pushAppendAndReduce(ctx,
|
||||
smsConfigWriteModel,
|
||||
instance.NewSMSConfigHTTPAddedEvent(
|
||||
@@ -182,6 +189,7 @@ func (c *Commands) AddSMSConfigHTTP(ctx context.Context, config *AddSMSHTTP) (er
|
||||
config.ID,
|
||||
config.Description,
|
||||
config.Endpoint,
|
||||
code.Crypted,
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -196,8 +204,10 @@ type ChangeSMSHTTP struct {
|
||||
ResourceOwner string
|
||||
ID string
|
||||
|
||||
Description *string
|
||||
Endpoint *string
|
||||
Description *string
|
||||
Endpoint *string
|
||||
ExpirationSigningKey bool
|
||||
SigningKey *string
|
||||
}
|
||||
|
||||
func (c *Commands) ChangeSMSConfigHTTP(ctx context.Context, config *ChangeSMSHTTP) (err error) {
|
||||
@@ -214,12 +224,24 @@ func (c *Commands) ChangeSMSConfigHTTP(ctx context.Context, config *ChangeSMSHTT
|
||||
if !smsConfigWriteModel.State.Exists() || smsConfigWriteModel.HTTP == nil {
|
||||
return zerrors.ThrowNotFound(nil, "COMMAND-6NW4I5Kqzj", "Errors.SMSConfig.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 := smsConfigWriteModel.NewHTTPChangedEvent(
|
||||
ctx,
|
||||
InstanceAggregateFromWriteModel(&smsConfigWriteModel.WriteModel),
|
||||
config.ID,
|
||||
config.Description,
|
||||
config.Endpoint)
|
||||
config.Endpoint,
|
||||
changedSigningKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user