mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-21 23:14:26 +00:00
# Which Problems Are Solved The payload in actions V2 is currently sent as JSON to the target endpoint. It might get exposed to intermediary infrastructure or logging systems. For these scenarios there needs to be an application-layer encryption, where the provider of the endpoint can define an key to be used for the encryption. # How the Problems Are Solved - Added an additional option to the target to specify the payload type: `JSON` (current and default), `JWT`, `JWE` (api and console) - added endpoints to upload and manage public keys (to be used for encryption) for a target - updated all action v2 executions (interceptors, oidc, saml, ...) to provide the `GetActiveSigningWebKey` from queries - implemented jwt and jwe in the exections incl. refactoring of code and tests - changes to the authn_keys table: - added a `fingerprint` column - dropped not null constraint on expiration - moved the `GetSignerOnce` into its own package to prevent circular dependencies # Additional Changes None # Additional Context closes #11061 --------- Co-authored-by: Marco A. <[email protected]> Co-authored-by: conblem <[email protected]> Co-authored-by: Silvan <[email protected]>
123 lines
3.0 KiB
Go
123 lines
3.0 KiB
Go
package target
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
const (
|
|
keyEventTypePrefix eventstore.EventType = "target.key."
|
|
KeyAddedEventType = keyEventTypePrefix + "added"
|
|
KeyActivatedEventType = keyEventTypePrefix + "activated"
|
|
KeyDeactivatedEventType = keyEventTypePrefix + "deactivated"
|
|
KeyRemovedEventType = keyEventTypePrefix + "removed"
|
|
)
|
|
|
|
type KeyAddedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
KeyID string `json:"keyId,omitempty"`
|
|
PublicKey []byte `json:"publicKey,omitempty"`
|
|
Fingerprint string `json:"fingerprint,omitempty"`
|
|
ExpirationDate time.Time `json:"expirationDate,omitzero"`
|
|
}
|
|
|
|
func (e *KeyAddedEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
|
e.BaseEvent = *b
|
|
}
|
|
|
|
func (e *KeyAddedEvent) Payload() any {
|
|
return e
|
|
}
|
|
|
|
func (e *KeyAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewKeyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
keyID string,
|
|
publicKey []byte,
|
|
fingerprint string,
|
|
expiration time.Time,
|
|
) *KeyAddedEvent {
|
|
return &KeyAddedEvent{
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
ctx, aggregate, KeyAddedEventType,
|
|
),
|
|
KeyID: keyID,
|
|
PublicKey: publicKey,
|
|
Fingerprint: fingerprint,
|
|
ExpirationDate: expiration,
|
|
}
|
|
}
|
|
|
|
type KeyActivatedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
KeyID string `json:"keyId,omitempty"`
|
|
}
|
|
|
|
func (e *KeyActivatedEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
|
e.BaseEvent = *b
|
|
}
|
|
|
|
func (e *KeyActivatedEvent) Payload() any {
|
|
return e
|
|
}
|
|
|
|
func (e *KeyActivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewKeyActivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate, id string) *KeyActivatedEvent {
|
|
return &KeyActivatedEvent{*eventstore.NewBaseEventForPush(ctx, aggregate, KeyActivatedEventType), id}
|
|
}
|
|
|
|
type KeyDeactivatedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
KeyID string `json:"keyId,omitempty"`
|
|
}
|
|
|
|
func (e *KeyDeactivatedEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
|
e.BaseEvent = *b
|
|
}
|
|
|
|
func (e *KeyDeactivatedEvent) Payload() any {
|
|
return e
|
|
}
|
|
|
|
func (e *KeyDeactivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewKeyDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate, id string) *KeyDeactivatedEvent {
|
|
return &KeyDeactivatedEvent{*eventstore.NewBaseEventForPush(ctx, aggregate, KeyDeactivatedEventType), id}
|
|
}
|
|
|
|
type KeyRemovedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
KeyID string `json:"keyId,omitempty"`
|
|
}
|
|
|
|
func (e *KeyRemovedEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
|
e.BaseEvent = *b
|
|
}
|
|
|
|
func (e *KeyRemovedEvent) Payload() any {
|
|
return e
|
|
}
|
|
|
|
func (e *KeyRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewKeyRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, id string) *KeyRemovedEvent {
|
|
return &KeyRemovedEvent{*eventstore.NewBaseEventForPush(ctx, aggregate, KeyRemovedEventType), id}
|
|
}
|