more work done
This commit is contained in:
parent
09fe1cd163
commit
6fda229a8e
23 changed files with 384 additions and 177 deletions
|
|
@ -1,10 +1,12 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"git.gitfish.de/ston1th/haproxy-lb/pkg/config"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/config"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
weakrand "math/rand"
|
||||
"net/http"
|
||||
//"net/http"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -90,7 +92,7 @@ func (a *auth) Auth(user, pass, path string) bool {
|
|||
a.bcryptMtx.Unlock()
|
||||
|
||||
authOk = err == nil
|
||||
u.cache.set(cacheKey, authOk)
|
||||
a.cache.set(cacheKey, authOk)
|
||||
}
|
||||
|
||||
return authOk && valid && strings.HasPrefix(path, creds.Prefix)
|
||||
|
|
@ -103,10 +105,10 @@ type creds struct {
|
|||
|
||||
func newAuth(conf config.Config) (a *auth) {
|
||||
a = &auth{
|
||||
users: make(map[string]creds),
|
||||
users: make(map[string]*creds),
|
||||
cache: newCache(),
|
||||
}
|
||||
for _, u := range conf.BasicAuth {
|
||||
for _, u := range conf.Server.BasicAuth {
|
||||
a.users[u.User] = &creds{u.Hash, u.Prefix}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue