mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-04 07:08:32 +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
33 lines
664 B
Go
33 lines
664 B
Go
package authhttp
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/patrickmn/go-cache"
|
|
)
|
|
|
|
type authCache struct {
|
|
action string
|
|
username string
|
|
clientID string
|
|
password string
|
|
topic string
|
|
}
|
|
|
|
var (
|
|
// cache = make(map[string]authCache)
|
|
c = cache.New(5*time.Minute, 10*time.Minute)
|
|
)
|
|
|
|
func checkCache(action, clientID, username, password, topic string) *authCache {
|
|
authc, found := c.Get(username)
|
|
if found {
|
|
return authc.(*authCache)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func addCache(action, clientID, username, password, topic string) {
|
|
c.Set(username, &authCache{action: action, username: username, clientID: clientID, password: password, topic: topic}, cache.DefaultExpiration)
|
|
}
|