Files
zitadel/backend/v3/domain/defaults.go
T
Marco A.andGitHub 701bca6003 feat(session): TOTP Check API with relation tables (#11886)
# Which Problems Are Solved

As part of #11035 , this PR implements the TOTP check logic for session
validation

# How the Problems Are Solved

  - Implement TOTP check logic and tests
- The tarpit function has been moved to a common file so that it can be
used by both TOTP and password checks
- Manual transaction management to avoid stalling the DB while verifier
function is executed
- Update `database.Change` `Matches()` function to allow comparison of
`time.Time` values
  - A converter package from GRPC to Domain model has been added

# Additional Context

This is a cherry-picked PR + changes, coming from
https://github.com/zitadel/zitadel/pull/11164
- Relates to #11035
2026-04-01 11:34:03 +02:00

63 lines
1.7 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"
"github.com/zitadel/zitadel/internal/webauthn"
)
var (
pool database.Pool
legacyEventstore eventstore.LegacyEventstore
sysConfig systemdefaults.SystemDefaults
passwordHasher *crypto.Hasher
idpEncryptionAlgo crypto.EncryptionAlgorithm
sessionTokenDecryptor SessionTokenDecryptor
mfaEncryptionAlgo crypto.EncryptionAlgorithm
otpSMSSecretGeneratorConfig *crypto.GeneratorConfig
otpEmailSecretGeneratorConfig *crypto.GeneratorConfig
webauthnConfig *webauthn.Config
)
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 SetWebAuthNConfig(cfg *webauthn.Config) {
webauthnConfig = cfg
}
func SetOTPEmailSecretGeneratorConfig(cfg *crypto.GeneratorConfig) {
otpEmailSecretGeneratorConfig = cfg
}
func SetMFAEncryptionAlgorithm(mfaEncryptionAlg crypto.EncryptionAlgorithm) {
mfaEncryptionAlgo = mfaEncryptionAlg
}