mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 01:26:18 -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 {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user