Skip to content

Commit 69fcd7e

Browse files
backport of commit 078585b (#31424)
Co-authored-by: mickael-hc <[email protected]>
1 parent 9a6a568 commit 69fcd7e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

changelog/31421.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
identity/mfa: revert cache entry change from #31217 and document cache entry values
3+
```

vault/external_tests/identity/login_mfa_totp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
329329
// let's make sure the configID is not blocked for other users
330330
doTwoPhaseLogin(t, userClient2, enginePath2, methodID, testuser2)
331331

332-
// let's see if user1 is able to login after 3 + 3*2 = 9 seconds
332+
// let's see if user1 is able to login after 3 * (2+1) = 9 seconds
333333
time.Sleep(9 * time.Second)
334334
doTwoPhaseLogin(t, userClient1, enginePath1, methodID, testuser1)
335335

vault/login_mfa.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,9 +2343,10 @@ func (c *Core) validateTOTP(ctx context.Context, mfaFactors *MFAFactor, entityMe
23432343
return fmt.Errorf("failed to validate TOTP passcode")
23442344
}
23452345

2346-
// The duration in which a passcode is stored in cache to enforce
2347-
// rate limit on failed totp passcode validation
2348-
passcodeTTL := time.Duration(int64(time.Second) * int64(totpSecret.Period) * int64(2*totpSecret.Skew))
2346+
// The duration in which a rateLimitID (configID_entityID) is used to limit the number of TOTP validation attempts.
2347+
// The passcode will be added to the usedCodes cache later, with a different TTL, with the skew and period.
2348+
passcodeTTL := time.Duration(int64(time.Second) * int64(totpSecret.Period))
2349+
23492350
// Enforcing rate limit per MethodID per EntityID
23502351
rateLimitID := fmt.Sprintf("%s_%s", configID, entityID)
23512352

0 commit comments

Comments
 (0)