mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
Extend htpasswd auth cache entry expiry on use
This commit is contained in:
parent
1eeca53812
commit
df9eb337d3
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue