项目作者: billcobbler

项目描述 :
Redis watcher for Casbin https://github.com/casbin/casbin
高级语言: Go
项目地址: git://github.com/billcobbler/casbin-redis-watcher.git
创建时间: 2018-05-31T15:30:20Z
项目社区:https://github.com/billcobbler/casbin-redis-watcher

开源协议:Apache License 2.0

下载


Redis Watcher Build Status

Redis Watcher is a Redis watcher for Casbin.

Installation

  1. go get github.com/billcobbler/casbin-redis-watcher/v2

Simple Example

  1. package main
  2. import (
  3. "github.com/casbin/casbin"
  4. "github.com/casbin/casbin/util"
  5. "github.com/billcobbler/casbin-redis-watcher/v2"
  6. )
  7. func updateCallback(msg string) {
  8. util.LogPrint(msg)
  9. }
  10. func main() {
  11. // Initialize the watcher.
  12. // Use the Redis host as parameter.
  13. w, _ := rediswatcher.NewWatcher("127.0.0.1:6379")
  14. // Initialize the enforcer.
  15. e := casbin.NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv")
  16. // Set the watcher for the enforcer.
  17. e.SetWatcher(w)
  18. // Set callback to local example
  19. w.SetUpdateCallback(updateCallback)
  20. // Update the policy to test the effect.
  21. // You should see "[casbin rules updated]" in the log.
  22. e.SavePolicy()
  23. }

Getting Help

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.