mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-28 23:18:54 +00:00
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:
co-authored by
Copilot
Marco A.
parent
826039c620
commit
3903355d18
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const _SettingTypeName = "loginbrandingpassword_complexitypassword_expirydomainlockoutsecurityorganizationnotificationlegal_and_support"
|
||||
const _SettingTypeName = "loginbrandingpassword_complexitypassword_expirydomainlockoutsecurityorganizationnotificationlegal_and_supportsecret_generator"
|
||||
|
||||
var _SettingTypeIndex = [...]uint8{0, 5, 13, 32, 47, 53, 60, 68, 80, 92, 109}
|
||||
var _SettingTypeIndex = [...]uint8{0, 5, 13, 32, 47, 53, 60, 68, 80, 92, 109, 125}
|
||||
|
||||
const _SettingTypeLowerName = "loginbrandingpassword_complexitypassword_expirydomainlockoutsecurityorganizationnotificationlegal_and_support"
|
||||
const _SettingTypeLowerName = "loginbrandingpassword_complexitypassword_expirydomainlockoutsecurityorganizationnotificationlegal_and_supportsecret_generator"
|
||||
|
||||
func (i SettingType) String() string {
|
||||
if i >= SettingType(len(_SettingTypeIndex)-1) {
|
||||
@@ -35,31 +35,34 @@ func _SettingTypeNoOp() {
|
||||
_ = x[SettingTypeOrganization-(7)]
|
||||
_ = x[SettingTypeNotification-(8)]
|
||||
_ = x[SettingTypeLegalAndSupport-(9)]
|
||||
_ = x[SettingTypeSecretGenerator-(10)]
|
||||
}
|
||||
|
||||
var _SettingTypeValues = []SettingType{SettingTypeLogin, SettingTypeBranding, SettingTypePasswordComplexity, SettingTypePasswordExpiry, SettingTypeDomain, SettingTypeLockout, SettingTypeSecurity, SettingTypeOrganization, SettingTypeNotification, SettingTypeLegalAndSupport}
|
||||
var _SettingTypeValues = []SettingType{SettingTypeLogin, SettingTypeBranding, SettingTypePasswordComplexity, SettingTypePasswordExpiry, SettingTypeDomain, SettingTypeLockout, SettingTypeSecurity, SettingTypeOrganization, SettingTypeNotification, SettingTypeLegalAndSupport, SettingTypeSecretGenerator}
|
||||
|
||||
var _SettingTypeNameToValueMap = map[string]SettingType{
|
||||
_SettingTypeName[0:5]: SettingTypeLogin,
|
||||
_SettingTypeLowerName[0:5]: SettingTypeLogin,
|
||||
_SettingTypeName[5:13]: SettingTypeBranding,
|
||||
_SettingTypeLowerName[5:13]: SettingTypeBranding,
|
||||
_SettingTypeName[13:32]: SettingTypePasswordComplexity,
|
||||
_SettingTypeLowerName[13:32]: SettingTypePasswordComplexity,
|
||||
_SettingTypeName[32:47]: SettingTypePasswordExpiry,
|
||||
_SettingTypeLowerName[32:47]: SettingTypePasswordExpiry,
|
||||
_SettingTypeName[47:53]: SettingTypeDomain,
|
||||
_SettingTypeLowerName[47:53]: SettingTypeDomain,
|
||||
_SettingTypeName[53:60]: SettingTypeLockout,
|
||||
_SettingTypeLowerName[53:60]: SettingTypeLockout,
|
||||
_SettingTypeName[60:68]: SettingTypeSecurity,
|
||||
_SettingTypeLowerName[60:68]: SettingTypeSecurity,
|
||||
_SettingTypeName[68:80]: SettingTypeOrganization,
|
||||
_SettingTypeLowerName[68:80]: SettingTypeOrganization,
|
||||
_SettingTypeName[80:92]: SettingTypeNotification,
|
||||
_SettingTypeLowerName[80:92]: SettingTypeNotification,
|
||||
_SettingTypeName[92:109]: SettingTypeLegalAndSupport,
|
||||
_SettingTypeLowerName[92:109]: SettingTypeLegalAndSupport,
|
||||
_SettingTypeName[0:5]: SettingTypeLogin,
|
||||
_SettingTypeLowerName[0:5]: SettingTypeLogin,
|
||||
_SettingTypeName[5:13]: SettingTypeBranding,
|
||||
_SettingTypeLowerName[5:13]: SettingTypeBranding,
|
||||
_SettingTypeName[13:32]: SettingTypePasswordComplexity,
|
||||
_SettingTypeLowerName[13:32]: SettingTypePasswordComplexity,
|
||||
_SettingTypeName[32:47]: SettingTypePasswordExpiry,
|
||||
_SettingTypeLowerName[32:47]: SettingTypePasswordExpiry,
|
||||
_SettingTypeName[47:53]: SettingTypeDomain,
|
||||
_SettingTypeLowerName[47:53]: SettingTypeDomain,
|
||||
_SettingTypeName[53:60]: SettingTypeLockout,
|
||||
_SettingTypeLowerName[53:60]: SettingTypeLockout,
|
||||
_SettingTypeName[60:68]: SettingTypeSecurity,
|
||||
_SettingTypeLowerName[60:68]: SettingTypeSecurity,
|
||||
_SettingTypeName[68:80]: SettingTypeOrganization,
|
||||
_SettingTypeLowerName[68:80]: SettingTypeOrganization,
|
||||
_SettingTypeName[80:92]: SettingTypeNotification,
|
||||
_SettingTypeLowerName[80:92]: SettingTypeNotification,
|
||||
_SettingTypeName[92:109]: SettingTypeLegalAndSupport,
|
||||
_SettingTypeLowerName[92:109]: SettingTypeLegalAndSupport,
|
||||
_SettingTypeName[109:125]: SettingTypeSecretGenerator,
|
||||
_SettingTypeLowerName[109:125]: SettingTypeSecretGenerator,
|
||||
}
|
||||
|
||||
var _SettingTypeNames = []string{
|
||||
@@ -73,6 +76,7 @@ var _SettingTypeNames = []string{
|
||||
_SettingTypeName[68:80],
|
||||
_SettingTypeName[80:92],
|
||||
_SettingTypeName[92:109],
|
||||
_SettingTypeName[109:125],
|
||||
}
|
||||
|
||||
// SettingTypeString retrieves an enum value from the enum constants string name.
|
||||
|
||||
Reference in New Issue
Block a user