mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
Extend htpasswd auth cache entry expiry on use
This commit is contained in:
committed by
Leo R. Lundgren
parent
1eeca53812
commit
df9eb337d3
@@ -234,6 +234,14 @@ func (h *HtpasswdFile) Validate(user string, password string) bool {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user