feat(action v2): add JWT and JWE payload type options (#11196)

# 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]>
This commit is contained in:
Livio Spring
2025-12-29 13:35:53 +00:00
committed by GitHub
co-authored by Marco A. conblem Silvan
parent 72c8f0192c
commit 791d0587aa
124 changed files with 5040 additions and 782 deletions
+27
View File
@@ -0,0 +1,27 @@
package setup
import (
"context"
_ "embed"
"github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
)
var (
//go:embed 68.sql
targetAddPayloadTypeAndKeyFingerprintColumn string
)
type TargetAddPayloadTypeColumn struct {
dbClient *database.DB
}
func (mig *TargetAddPayloadTypeColumn) Execute(ctx context.Context, _ eventstore.Event) error {
_, err := mig.dbClient.ExecContext(ctx, targetAddPayloadTypeAndKeyFingerprintColumn)
return err
}
func (mig *TargetAddPayloadTypeColumn) String() string {
return "68_target2_add_payload_type_authn_key2_fingerprint_expiration"
}
+8
View File
@@ -0,0 +1,8 @@
ALTER TABLE IF EXISTS projections.targets2
ADD COLUMN IF NOT EXISTS payload_type smallint default 0;
ALTER TABLE IF EXISTS projections.authn_keys2
ADD COLUMN IF NOT EXISTS fingerprint text;
ALTER TABLE IF EXISTS projections.authn_keys2
ALTER COLUMN expiration DROP NOT NULL;
+1
View File
@@ -164,6 +164,7 @@ type Steps struct {
s65FixUserMetadata5Index *FixUserMetadata5Index
s66SessionRecoveryCodeCheckedAt *SessionRecoveryCodeCheckedAt
s67SyncMemberRoleFields *SyncMemberRoleFields
s68TargetAddPayloadTypeColumn *TargetAddPayloadTypeColumn
}
func MustNewSteps(v *viper.Viper) *Steps {
+2
View File
@@ -225,6 +225,7 @@ func Setup(ctx context.Context, config *Config, steps *Steps, masterKey string)
steps.s65FixUserMetadata5Index = &FixUserMetadata5Index{dbClient: dbClient}
steps.s66SessionRecoveryCodeCheckedAt = &SessionRecoveryCodeCheckedAt{dbClient: dbClient}
steps.s67SyncMemberRoleFields = &SyncMemberRoleFields{dbClient: dbClient}
steps.s68TargetAddPayloadTypeColumn = &TargetAddPayloadTypeColumn{dbClient: dbClient}
err = projection.Create(ctx, dbClient, eventstoreClient, config.Projections, nil, nil, nil)
logging.OnError(err).Fatal("unable to start projections")
@@ -342,6 +343,7 @@ func Setup(ctx context.Context, config *Config, steps *Steps, masterKey string)
steps.s48Apps7SAMLConfigsLoginVersion,
steps.s59SetupWebkeys, // this step needs commands.
steps.s66SessionRecoveryCodeCheckedAt,
steps.s68TargetAddPayloadTypeColumn,
} {
setupErr = executeMigration(ctx, eventstoreClient, step, "migration failed")
if setupErr != nil {
-1
View File
@@ -19,7 +19,6 @@ func (mig *TransactionalTables) Execute(ctx context.Context, _ eventstore.Event)
if err != nil {
return err
}
return pool.Migrate(ctx)
}
+1
View File
@@ -331,6 +331,7 @@ func startZitadel(ctx context.Context, config *Config, masterKey string, server
config.Executions,
q,
keys.Target,
queries.GetActiveSigningWebKey,
)
execution.Start(ctx)