Skip to content

Commit 6b0d804

Browse files
committed
fix: review comments
1 parent f9b1aeb commit 6b0d804

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

internal/service/auth_service.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
// but for now these are just safety limits to prevent unbounded memory usage
2626
const MaxOAuthPendingSessions = 256
2727
const OAuthCleanupCount = 16
28-
const MaxLoginAttemptRecords = 5
28+
const MaxLoginAttemptRecords = 256
2929

3030
type OAuthPendingSession struct {
3131
State string
@@ -242,6 +242,9 @@ func (auth *AuthService) RecordLoginAttempt(identifier string, success bool) {
242242
defer auth.loginMutex.Unlock()
243243

244244
if len(auth.loginAttempts) >= MaxLoginAttemptRecords {
245+
if auth.lockdown != nil || !auth.lockdown.Active {
246+
return
247+
}
245248
go auth.lockdownMode()
246249
return
247250
}
@@ -780,11 +783,11 @@ func (auth *AuthService) lockdownMode() {
780783
// we might as well clear them to free up memory
781784
auth.loginAttempts = make(map[string]*LoginAttempt)
782785

783-
auth.loginMutex.Unlock()
784-
785786
timer := time.NewTimer(time.Until(auth.lockdown.ActiveUntil))
786787
defer timer.Stop()
787788

789+
auth.loginMutex.Unlock()
790+
788791
<-timer.C
789792

790793
auth.loginMutex.Lock()

0 commit comments

Comments
 (0)