mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-25 16:07:54 +00:00
fix: review comments
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
// but for now these are just safety limits to prevent unbounded memory usage
|
||||
const MaxOAuthPendingSessions = 256
|
||||
const OAuthCleanupCount = 16
|
||||
const MaxLoginAttemptRecords = 5
|
||||
const MaxLoginAttemptRecords = 256
|
||||
|
||||
type OAuthPendingSession struct {
|
||||
State string
|
||||
@@ -242,6 +242,9 @@ func (auth *AuthService) RecordLoginAttempt(identifier string, success bool) {
|
||||
defer auth.loginMutex.Unlock()
|
||||
|
||||
if len(auth.loginAttempts) >= MaxLoginAttemptRecords {
|
||||
if auth.lockdown != nil || !auth.lockdown.Active {
|
||||
return
|
||||
}
|
||||
go auth.lockdownMode()
|
||||
return
|
||||
}
|
||||
@@ -780,11 +783,11 @@ func (auth *AuthService) lockdownMode() {
|
||||
// we might as well clear them to free up memory
|
||||
auth.loginAttempts = make(map[string]*LoginAttempt)
|
||||
|
||||
auth.loginMutex.Unlock()
|
||||
|
||||
timer := time.NewTimer(time.Until(auth.lockdown.ActiveUntil))
|
||||
defer timer.Stop()
|
||||
|
||||
auth.loginMutex.Unlock()
|
||||
|
||||
<-timer.C
|
||||
|
||||
auth.loginMutex.Lock()
|
||||
|
||||
Reference in New Issue
Block a user