This commit is contained in:
joy.zhou
2019-07-25 13:47:27 +08:00
parent cab26d502a
commit fa7f984903

View File

@@ -2,6 +2,7 @@ package authhttp
import ( import (
"encoding/json" "encoding/json"
"io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
@@ -88,10 +89,12 @@ func CheckAuth(clientID, username, password string) bool {
} }
defer resp.Body.Close() defer resp.Body.Close()
io.Copy(ioutil.Discard, resp.Body)
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
addCache(action, clientID, username, password, "") addCache(action, clientID, username, password, "")
return true return true
} }
return false return false
} }
@@ -127,6 +130,8 @@ func CheckSuper(clientID, username, password string) bool {
} }
defer resp.Body.Close() defer resp.Body.Close()
io.Copy(ioutil.Discard, resp.Body)
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
return true return true
} }
@@ -165,6 +170,8 @@ func CheckACL(username, access, topic string) bool {
} }
defer resp.Body.Close() defer resp.Body.Close()
io.Copy(ioutil.Discard, resp.Body)
if resp.StatusCode == http.StatusOK { if resp.StatusCode == http.StatusOK {
addCache(action, "", username, "", topic) addCache(action, "", username, "", topic)
return true return true