mirror of
https://github.com/fhmq/hmq.git
synced 2026-04-24 10:38:34 +00:00
Bugfix - authfile plugin did wrongly use username as IP and IP as username in ACL checks (#100)
* adding test + fix issue with wrong order in acl check * reduce to featureset from original fork
This commit is contained in:
@@ -19,5 +19,5 @@ func (a *aclAuth) CheckConnect(clientID, username, password string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *aclAuth) CheckACL(action, clientID, username, ip, topic string) bool {
|
func (a *aclAuth) CheckACL(action, clientID, username, ip, topic string) bool {
|
||||||
return checkTopicAuth(a.config, action, username, ip, clientID, topic)
|
return checkTopicAuth(a.config, action, ip, username, clientID, topic)
|
||||||
}
|
}
|
||||||
|
|||||||
23
plugins/auth/authfile/acl_test.go
Normal file
23
plugins/auth/authfile/acl_test.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
//+build test
|
||||||
|
|
||||||
|
package acl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOrigAcls(t *testing.T) {
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
|
os.Chdir("../../../")
|
||||||
|
aclOrig := Init()
|
||||||
|
os.Chdir(pwd)
|
||||||
|
|
||||||
|
// rule: allow ip 127.0.0.1 2 $SYS/#
|
||||||
|
origAllowed := aclOrig.CheckACL(PUB, "dummyClientID", "dummyUser", "127.0.0.1", "$SYS/something")
|
||||||
|
assert.True(t, origAllowed)
|
||||||
|
origAllowed = aclOrig.CheckACL(SUB, "dummyClientID", "dummyUser", "127.0.0.1", "$SYS/something")
|
||||||
|
assert.False(t, origAllowed)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user