Skip to content

Casbin Redis Watcher is a Go library meant to be used as a Casbin Watcher.

License

Notifications You must be signed in to change notification settings

escaletech/casbin-redis-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Casbin Redis Watcher

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.

Installation

go get github.com/escaletech/casbin-redis-watcher/watcher

Usage

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
}

License

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

About

Casbin Redis Watcher is a Go library meant to be used as a Casbin Watcher.

Resources

License

Stars

Watchers

Forks

Packages

No packages published