feat(settings): add secret generator type to settings RT implementation (#11152)

# Which Problems Are Solved

The `SecretGenerators` setting is missing among the instance settings in
the new relational model.

# How the Problems Are Solved

This PR adds:
* `SettingTypeSecretGenerator` type to the settings model
* `SecretGeneratorSettingsRepository` and
`secretGeneratorSettingsJSONChanges` interfaces to set, retrieve, and
delete `secret_generator` settings, and corresponding unit tests.
* projection reducers to reduce the following events:
  * `SecretGeneratorAddedEvent`
  * `SecretGeneratorChangedEvent`
  * `SecretGeneratorRemovedEvent`
* integration tests to test that the events get reduced correctly 

# Additional Changes
N/A

# Additional Context
- Part of https://github.com/zitadel/zitadel/issues/10207

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
Gayathri Vijayan
2025-12-11 12:33:19 +01:00
committed by GitHub
co-authored by Copilot Marco A.
parent 826039c620
commit 3903355d18
9 changed files with 2209 additions and 49 deletions
+87
View File
@@ -23,6 +23,7 @@ const (
SettingTypeOrganization
SettingTypeNotification
SettingTypeLegalAndSupport
SettingTypeSecretGenerator
)
//go:generate enumer -type SettingState -transform snake -trimprefix SettingState -sql
@@ -428,3 +429,89 @@ type LegalAndSupportSettingsRepository interface {
settingsRepository[LegalAndSupportSettings]
legalAndSupportSettingsJSONChanges
}
type SecretGeneratorSettings struct {
Settings
SecretGeneratorSettingsAttributes
}
//go:generate mockgen -typed -package domainmock -destination ./mock/secret_generator_settings.mock.go . SecretGeneratorSettingsRepository
type SecretGeneratorSettingsRepository interface {
settingsRepository[SecretGeneratorSettings]
secretGeneratorSettingsJSONChanges
}
type secretGeneratorSettingsJSONChanges interface {
SetSettingFields(value SecretGeneratorSettingsAttributes) database.Change
SetClientSecret(value ClientSecretAttributes) db_json.JsonUpdate
SetInitializeUserCode(value InitializeUserCodeAttributes) db_json.JsonUpdate
SetEmailVerificationCode(value EmailVerificationCodeAttributes) db_json.JsonUpdate
SetPhoneVerificationCode(value PhoneVerificationCodeAttributes) db_json.JsonUpdate
SetPasswordVerificationCode(value PasswordVerificationCodeAttributes) db_json.JsonUpdate
SetPasswordlessInitCode(value PasswordlessInitCodeAttributes) db_json.JsonUpdate
SetDomainVerification(value DomainVerificationAttributes) db_json.JsonUpdate
SetOTPSMS(value OTPSMSAttributes) db_json.JsonUpdate
SetOTPEmail(value OTPEmailAttributes) db_json.JsonUpdate
}
type SecretGeneratorSettingsAttributes struct {
ClientSecret *ClientSecretAttributes `json:"clientSecret,omitempty"`
InitializeUserCode *InitializeUserCodeAttributes `json:"initializeUserCode,omitempty"`
EmailVerificationCode *EmailVerificationCodeAttributes `json:"emailVerificationCode,omitempty"`
PhoneVerificationCode *PhoneVerificationCodeAttributes `json:"phoneVerificationCode,omitempty"`
PasswordVerificationCode *PasswordVerificationCodeAttributes `json:"passwordVerificationCode,omitempty"`
PasswordlessInitCode *PasswordlessInitCodeAttributes `json:"passwordlessInitCode,omitempty"`
DomainVerification *DomainVerificationAttributes `json:"domainVerification,omitempty"`
OTPSMS *OTPSMSAttributes `json:"otpSms,omitempty"`
OTPEmail *OTPEmailAttributes `json:"otpEmail,omitempty"`
}
type ClientSecretAttributes struct {
SecretGeneratorAttrs
}
type InitializeUserCodeAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type EmailVerificationCodeAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type PhoneVerificationCodeAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type PasswordVerificationCodeAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type PasswordlessInitCodeAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type DomainVerificationAttributes struct {
SecretGeneratorAttrs
}
type OTPSMSAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type OTPEmailAttributes struct {
SecretGeneratorAttrsWithExpiry
}
type SecretGeneratorAttrs struct {
Length *uint `json:"length,omitempty"`
IncludeLowerLetters *bool `json:"includeLowerLetters,omitempty"`
IncludeUpperLetters *bool `json:"includeUpperLetters,omitempty"`
IncludeDigits *bool `json:"includeDigits,omitempty"`
IncludeSymbols *bool `json:"includeSymbols,omitempty"`
}
type SecretGeneratorAttrsWithExpiry struct {
Expiry *time.Duration `json:"expiry,omitempty"`
SecretGeneratorAttrs
}