mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-01 16:38:52 +00:00
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
This commit is contained in:
@@ -15,11 +15,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
// tarpitFn represents a tarpit function
|
||||
//
|
||||
// The input is the number of failed attempts after which the tarpit is started
|
||||
type tarpitFn func(failedAttempts uint64)
|
||||
|
||||
type CheckPasswordType struct {
|
||||
Password string
|
||||
}
|
||||
@@ -55,7 +50,7 @@ type PasswordCheckCommand struct {
|
||||
// and an input password to verify. It returns an updated hash and an error.
|
||||
// It defaults to [passwap.Swapper.Verify]
|
||||
//
|
||||
// The command does not implement [Transactional] due verifyFn that might take a long time to execute.
|
||||
// The command does not implement [Transactional] due to verifyFn that might take a long time to execute.
|
||||
// So the DB transaction will be started only after verifyFn has been run.
|
||||
//
|
||||
// Moreover, the command may return a functional error so manual management of the transaction is needed
|
||||
@@ -200,7 +195,7 @@ func (p *PasswordCheckCommand) GetPasswordCheckChanges(ctx context.Context, opts
|
||||
}
|
||||
case *VerificationTypeFailed:
|
||||
dbUpdates[0] = humanRepo.IncrementPasswordFailedAttempts()
|
||||
lockoutPolicy, err := GetLockoutPolicy(ctx, opts, p.InstanceID, p.FetchedUser.OrganizationID)
|
||||
lockoutPolicy, err := GetLockoutPolicy(ctx, opts.DB(), opts.lockoutSettingRepo, p.InstanceID, p.FetchedUser.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user