From 9fef7b668d891bd0f10beddb00cf1a352d2e5fcd Mon Sep 17 00:00:00 2001 From: "joy.zhou" Date: Mon, 15 Jul 2019 18:29:45 +0800 Subject: [PATCH] fixed --- broker/auth.go | 4 ++-- plugins/authhttp/authhttp.go | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/broker/auth.go b/broker/auth.go index 045e1d4..423536b 100644 --- a/broker/auth.go +++ b/broker/auth.go @@ -18,9 +18,9 @@ func (c *client) CheckTopicAuth(typ int, topic string) bool { access := "sub" switch typ { case 1: - access = "pub" + access = "2" case 2: - access = "sub" + access = "1" } username := string(c.info.username) return authhttp.CheckACL(username, access, topic) diff --git a/plugins/authhttp/authhttp.go b/plugins/authhttp/authhttp.go index e0fe382..0d82640 100644 --- a/plugins/authhttp/authhttp.go +++ b/plugins/authhttp/authhttp.go @@ -114,23 +114,18 @@ func CheckSuper(clientID, username, password string) bool { //CheckACL check mqtt connect func CheckACL(username, access, topic string) bool { - data := url.Values{} - data.Add("username", username) - data.Add("topic", topic) - data.Add("access", access) - - req, err := http.NewRequest("GET", config.ACLURL, strings.NewReader(data.Encode())) + req, err := http.NewRequest("GET", config.ACLURL, nil) if err != nil { log.Error("get acl: ", zap.Error(err)) return false } - // data := req.URL.Query() + data := req.URL.Query() - // data.Add("username", username) - // data.Add("topic", topic) - // data.Add("access", access) - // req.URL.RawQuery = data.Encode() + data.Add("username", username) + data.Add("topic", topic) + data.Add("access", access) + req.URL.RawQuery = data.Encode() // fmt.Println("req:", req) resp, err := httpClient.Do(req) if err != nil {