Extend htpasswd auth cache entry expiry on use

This commit is contained in:
Michael Eischer
2022-06-21 00:18:05 +02:00
committed by Leo R. Lundgren
parent 1eeca53812
commit df9eb337d3
+8
View File
@@ -234,6 +234,14 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
} }
if cacheExists && subtle.ConstantTimeCompare(entry.verifier, hash.Sum(nil)) == 1 { if cacheExists && subtle.ConstantTimeCompare(entry.verifier, hash.Sum(nil)) == 1 {
h.mutex.Lock()
// repurpose mutex to prevent concurrent cache updates
// extend cache entry
cache[user] = cacheEntry{
verifier: entry.verifier,
expiry: time.Now().Add(PasswordCacheDuration),
}
h.mutex.Unlock()
return true return true
} }