mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
feat(v3alpha): web key resource (#8262)
# Which Problems Are Solved Implement a new API service that allows management of OIDC signing web keys. This allows users to manage rotation of the instance level keys. which are currently managed based on expiry. The API accepts the generation of the following key types and parameters: - RSA keys with 2048, 3072 or 4096 bit in size and: - Signing with SHA-256 (RS256) - Signing with SHA-384 (RS384) - Signing with SHA-512 (RS512) - ECDSA keys with - P256 curve - P384 curve - P512 curve - ED25519 keys # How the Problems Are Solved Keys are serialized for storage using the JSON web key format from the `jose` library. This is the format that will be used by OIDC for signing, verification and publication. Each instance can have a number of key pairs. All existing public keys are meant to be used for token verification and publication the keys endpoint. Keys can be activated and the active private key is meant to sign new tokens. There is always exactly 1 active signing key: 1. When the first key for an instance is generated, it is automatically activated. 2. Activation of the next key automatically deactivates the previously active key. 3. Keys cannot be manually deactivated from the API 4. Active keys cannot be deleted # Additional Changes - Query methods that later will be used by the OIDC package are already implemented. Preparation for #8031 - Fix indentation in french translation for instance event - Move user_schema translations to consistent positions in all translation files # Additional Context - Closes #8030 - Part of #7809 --------- Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
@@ -34,12 +34,20 @@ const (
|
||||
)
|
||||
|
||||
type InstanceSetup struct {
|
||||
zitadel ZitadelConfig
|
||||
InstanceName string
|
||||
CustomDomain string
|
||||
DefaultLanguage language.Tag
|
||||
Org InstanceOrgSetup
|
||||
SecretGenerators *SecretGenerators
|
||||
zitadel ZitadelConfig
|
||||
InstanceName string
|
||||
CustomDomain string
|
||||
DefaultLanguage language.Tag
|
||||
Org InstanceOrgSetup
|
||||
SecretGenerators *SecretGenerators
|
||||
WebKeys struct {
|
||||
Type crypto.WebKeyConfigType
|
||||
Config struct {
|
||||
RSABits crypto.RSABits
|
||||
RSAHasher crypto.RSAHasher
|
||||
EllipticCurve crypto.EllipticCurve
|
||||
}
|
||||
}
|
||||
PasswordComplexityPolicy struct {
|
||||
MinLength uint64
|
||||
HasLowercase bool
|
||||
@@ -267,6 +275,9 @@ func setUpInstance(ctx context.Context, c *Commands, setup *InstanceSetup) (vali
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
setupSMTPSettings(c, &validations, setup.SMTPConfiguration, instanceAgg)
|
||||
if err := setupWebKeys(c, &validations, setup.zitadel.instanceID, setup); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
setupOIDCSettings(c, &validations, setup.OIDCSettings, instanceAgg)
|
||||
setupFeatures(&validations, setup.Features, setup.zitadel.instanceID)
|
||||
setupLimits(c, &validations, limits.NewAggregate(setup.zitadel.limitsID, setup.zitadel.instanceID), setup.Limits)
|
||||
@@ -390,6 +401,29 @@ func setupFeatures(validations *[]preparation.Validation, features *InstanceFeat
|
||||
}
|
||||
}
|
||||
|
||||
func setupWebKeys(c *Commands, validations *[]preparation.Validation, instanceID string, setup *InstanceSetup) error {
|
||||
var conf crypto.WebKeyConfig
|
||||
switch setup.WebKeys.Type {
|
||||
case crypto.WebKeyConfigTypeUnspecified:
|
||||
return nil // config disabled, skip
|
||||
case crypto.WebKeyConfigTypeRSA:
|
||||
conf = &crypto.WebKeyRSAConfig{
|
||||
Bits: setup.WebKeys.Config.RSABits,
|
||||
Hasher: setup.WebKeys.Config.RSAHasher,
|
||||
}
|
||||
case crypto.WebKeyConfigTypeECDSA:
|
||||
conf = &crypto.WebKeyECDSAConfig{
|
||||
Curve: setup.WebKeys.Config.EllipticCurve,
|
||||
}
|
||||
case crypto.WebKeyConfigTypeED25519:
|
||||
conf = &crypto.WebKeyED25519Config{}
|
||||
default:
|
||||
return zerrors.ThrowInternalf(nil, "COMMAND-sieX0", "Errors.Internal unknown web key type %q", setup.WebKeys.Type)
|
||||
}
|
||||
*validations = append(*validations, c.prepareGenerateInitialWebKeys(instanceID, conf))
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupOIDCSettings(commands *Commands, validations *[]preparation.Validation, oidcSettings *OIDCSettings, instanceAgg *instance.Aggregate) {
|
||||
if oidcSettings == nil {
|
||||
return
|
||||
|
Reference in New Issue
Block a user