mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-01-22 05:19:26 +02:00
Merge pull request #1882 from babs/atrocious-fix-for-test-race-condition-on-htpasswd
Fix for test race condition on htpasswd file
This commit is contained in:
commit
9484a67afc
@ -8,6 +8,8 @@
|
||||
|
||||
## Changes since v7.4.0
|
||||
|
||||
- [#1882](https://github.com/oauth2-proxy/oauth2-proxy/pull/1882) Make `htpasswd.GetUsers` racecondition safe
|
||||
|
||||
# V7.4.0
|
||||
|
||||
## Release Highlights
|
||||
|
@ -139,6 +139,17 @@ func passShaOrBcrypt(h *htpasswdMap, user, password string) (invalidEntries []st
|
||||
return invalidEntries
|
||||
}
|
||||
|
||||
// GetUsers return a "thread safe" copy of the internal user list
|
||||
func (h *htpasswdMap) GetUsers() map[string]interface{} {
|
||||
newUserList := make(map[string]interface{})
|
||||
h.rwm.Lock()
|
||||
for key, value := range h.users {
|
||||
newUserList[key] = value
|
||||
}
|
||||
h.rwm.Unlock()
|
||||
return newUserList
|
||||
}
|
||||
|
||||
// Validate checks a users password against the htpasswd entries
|
||||
func (h *htpasswdMap) Validate(user string, password string) bool {
|
||||
realPassword, exists := h.users[user]
|
||||
|
@ -149,7 +149,7 @@ var _ = Describe("HTPasswd Suite", func() {
|
||||
fileNames = append(fileNames, file.Name())
|
||||
|
||||
It("has the correct number of users", func() {
|
||||
Expect(len(htpasswd.users)).To(Equal(hu.expectedLen))
|
||||
Expect(len(htpasswd.GetUsers())).To(Equal(hu.expectedLen))
|
||||
})
|
||||
|
||||
It(hu.testText, func() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user