mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
Try to zero htpasswd cache entries before deletion
This commit is contained in:
parent
0bdc420e75
commit
1eeca53812
1 changed files with 9 additions and 0 deletions
|
@ -120,8 +120,11 @@ func (h *HtpasswdFile) expiryTimer() {
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
|
var zeros [sha256.Size]byte
|
||||||
|
// try to wipe expired cache entries
|
||||||
for user, entry := range h.cache {
|
for user, entry := range h.cache {
|
||||||
if entry.expiry.After(now) {
|
if entry.expiry.After(now) {
|
||||||
|
copy(entry.verifier, zeros[:])
|
||||||
delete(h.cache, user)
|
delete(h.cache, user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +162,13 @@ func (h *HtpasswdFile) Reload() error {
|
||||||
|
|
||||||
// Replace the Users map
|
// Replace the Users map
|
||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
|
var zeros [sha256.Size]byte
|
||||||
|
// try to wipe the old cache entries
|
||||||
|
for _, entry := range h.cache {
|
||||||
|
copy(entry.verifier, zeros[:])
|
||||||
|
}
|
||||||
h.cache = make(map[string]cacheEntry)
|
h.cache = make(map[string]cacheEntry)
|
||||||
|
|
||||||
h.users = users
|
h.users = users
|
||||||
h.mutex.Unlock()
|
h.mutex.Unlock()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue