mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-02 14:28:34 +00:00
* modify * update * add acl * add feature * update dockerfile * add deploy * update * update * plugins * plugins * update * update * update * fixed * remove * fixed * add log * update * fixed * update * fix config * add http api * add http api * resp * add config for work chan * update * fixed * update * disable trace * fixed * change acl * fixed * fixed res * dd * dd * ddd * dd * update * fixed * update * add * fixed * update key * add log * update * format * update * update auth * update * update readme * added * update * fixed * fixed * fix * upade * update * update
44 lines
759 B
Go
44 lines
759 B
Go
/* Copyright (c) 2018, joy.zhou <chowyu08@gmail.com>
|
|
*/
|
|
package broker
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/fhmq/hmq/plugins/authhttp"
|
|
)
|
|
|
|
const (
|
|
SUB = "1"
|
|
PUB = "2"
|
|
)
|
|
|
|
func (b *Broker) CheckTopicAuth(action, username, topic string) bool {
|
|
if b.pluginAuthHTTP {
|
|
if strings.HasPrefix(topic, "$SYS/broker/connection/clients/") {
|
|
return true
|
|
}
|
|
|
|
if strings.HasPrefix(topic, "$queue/") {
|
|
topic = strings.TrimPrefix(topic, "$queue/")
|
|
}
|
|
|
|
return authhttp.CheckACL(username, action, topic)
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func (b *Broker) CheckConnectAuth(clientID, username, password string) bool {
|
|
if b.pluginAuthHTTP {
|
|
if clientID == "" || username == "" {
|
|
return false
|
|
}
|
|
return authhttp.CheckAuth(clientID, username, password)
|
|
}
|
|
|
|
return true
|
|
|
|
}
|