github.com/lei006/gmqtt-broker@v0.0.1/plugins/auth/auth.go (about) 1 package auth 2 3 import ( 4 authfile "github.com/lei006/gmqtt-broker/plugins/auth/authfile" 5 "github.com/lei006/gmqtt-broker/plugins/auth/authhttp" 6 ) 7 8 const ( 9 AuthHTTP = "authhttp" 10 AuthFile = "authfile" 11 ) 12 13 type Auth interface { 14 CheckACL(action, clientID, username, ip, topic string) bool 15 CheckConnect(clientID, username, password string) bool 16 } 17 18 func NewAuth(name string) Auth { 19 switch name { 20 case AuthHTTP: 21 return authhttp.Init() 22 case AuthFile: 23 return authfile.Init() 24 default: 25 return &mockAuth{} 26 } 27 }