mirror of
https://github.com/ginuerzh/gost.git
synced 2024-04-21 12:31:34 +00:00
add reloader for authenticator
This commit is contained in:
@@ -299,7 +299,7 @@ func (h *httpHandler) authenticate(conn net.Conn, req *http.Request, resp *http.
|
||||
log.Logf("[http] %s -> %s : Authorization '%s' '%s'",
|
||||
conn.RemoteAddr(), conn.LocalAddr(), u, p)
|
||||
}
|
||||
if authenticate(u, p, h.options.Users...) {
|
||||
if h.options.Authenticator == nil || h.options.Authenticator.Authenticate(u, p) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -423,20 +423,3 @@ func basicProxyAuth(proxyAuth string) (username, password string, ok bool) {
|
||||
|
||||
return cs[:s], cs[s+1:], true
|
||||
}
|
||||
|
||||
func authenticate(username, password string, users ...*url.Userinfo) bool {
|
||||
if len(users) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
u := user.Username()
|
||||
p, _ := user.Password()
|
||||
if (u == username && p == password) ||
|
||||
(u == username && p == "") ||
|
||||
(u == "" && p == password) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user