mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-02 04:12:16 +00:00
# Which Problems Are Solved This PR adds the OTP SMS Challenge needed for CreateSession API https://github.com/zitadel/zitadel/issues/11035 # How the Problems Are Solved - Introduce `OTPSMSChallengeCommand` (validate/execute/events) for session creation checks - Introduce `GetOTPCryptoGeneratorConfigWithDefault` to fetch per-instance secret generator settings - Add unit tests # Additional Changes Refactor tests in `session_check_recovery_code_test.go` to make the helper functions reusable in `session_challenge_otp_sms_test.go` # Additional Context Related to https://github.com/zitadel/zitadel/issues/11035
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package domain
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/backend/v3/storage/database"
|
|
"github.com/zitadel/zitadel/backend/v3/storage/eventstore"
|
|
"github.com/zitadel/zitadel/internal/config/systemdefaults"
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
)
|
|
|
|
var (
|
|
pool database.Pool
|
|
legacyEventstore eventstore.LegacyEventstore
|
|
sysConfig systemdefaults.SystemDefaults
|
|
passwordHasher *crypto.Hasher
|
|
idpEncryptionAlgo crypto.EncryptionAlgorithm
|
|
sessionTokenDecryptor SessionTokenDecryptor
|
|
mfaEncryptionAlgo crypto.EncryptionAlgorithm
|
|
otpSMSSecretGeneratorConfig *crypto.GeneratorConfig
|
|
)
|
|
|
|
func SetPool(p database.Pool) {
|
|
pool = p
|
|
}
|
|
|
|
func SetLegacyEventstore(es eventstore.LegacyEventstore) {
|
|
legacyEventstore = es
|
|
}
|
|
|
|
func SetSystemConfig(cfg systemdefaults.SystemDefaults) {
|
|
sysConfig = cfg
|
|
}
|
|
|
|
func SetPasswordHasher(hasher *crypto.Hasher) {
|
|
passwordHasher = hasher
|
|
}
|
|
|
|
func SetIDPEncryptionAlgorithm(idpEncryptionAlg crypto.EncryptionAlgorithm) {
|
|
idpEncryptionAlgo = idpEncryptionAlg
|
|
}
|
|
|
|
func SetSessionTokenDecryptor(decryptor SessionTokenDecryptor) {
|
|
sessionTokenDecryptor = decryptor
|
|
}
|
|
|
|
func SetOTPSMSSecretGeneratorConfig(cfg *crypto.GeneratorConfig) {
|
|
otpSMSSecretGeneratorConfig = cfg
|
|
}
|
|
|
|
func SetMFAEncryptionAlgorithm(mfaEncryptionAlg crypto.EncryptionAlgorithm) {
|
|
mfaEncryptionAlgo = mfaEncryptionAlg
|
|
}
|