Skip to content

Commit 4314f87

Browse files
committed
Reset authentication rate limit counters on successful password reset
This provides a secure mechanism for users that have made too many failed password authentication attempts to regain access to their account without having to wait for the rate limiting window to elapse.
1 parent 4ce0c55 commit 4314f87

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Buttercup.Security.Tests/PasswordAuthenticationServiceTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ await this.SecurityEventExists(
733733
this.authenticationMailerMock.Verify(
734734
x => x.SendPasswordChangeNotification(userBefore.Email));
735735

736+
// Resets the rate limit counters
737+
this.passwordAuthenticationRateLimiterMock.Verify(x => x.Reset(userBefore.Email));
738+
736739
// Returns updated user
737740
Assert.Equal(expectedUserAfter, result);
738741
}

src/Buttercup.Security/PasswordAuthenticationService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ await this.InsertSecurityEvent(
195195

196196
await this.authenticationMailer.SendPasswordChangeNotification(user.Email);
197197

198+
await this.passwordAuthenticationRateLimiter.Reset(user.Email);
199+
198200
return user;
199201
}
200202

0 commit comments

Comments
 (0)