Casbin Redis Watcher is a Go library meant to be used as a Casbin Watcher.
The main difference between this watcher and the currently recommended Redis Watcher is that this one supports using a Redis Cluster.
go get github.com/escaletech/casbin-redis-watcher/watcher
The simplest usage would be:
package main
import (
"github.com/casbin/casbin/v2"
"github.com/escaletech/casbin-redis-watcher/watcher"
)
func main() {
// Initialize the watcher
w, err := watcher.New(watcher.Options{
RedisURL: "redis://127.0.0.1:6379",
})
if err != nil {
panic(err)
}
// Create your enforcer
e := casbin.NewEnforcer("rbac_model.conf", "rbac_policy.csv")
// Tell the enforcer to use the watcher
e.SetWatcher(w)
// Now whenever e.SavePolicy() is called, the watcher is going to be notified
}
This project is under MIT License. See the LICENSE file for the full license text.