Casbin role watcher to be used for monitoring updates to policies for PyCasbin
Project description
redis-watcher
redis-watcher is the Redis watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.
Installation
pip install casbin-redis-watcher
Simple Example
import os
import casbin
from casbin_redis_watcher import new_watcher, WatcherOptions
def callback_function(event):
print("update for remove filtered policy callback, event: {}".format(event))
def get_examples(path):
examples_path = os.path.split(os.path.realpath(__file__))[0] + "/../examples/"
return os.path.abspath(examples_path + path)
if __name__ == "main":
test_option = WatcherOptions()
test_option.host = "localhost"
test_option.port = "6379"
test_option.channel = "test"
test_option.optional_update_callback = callback_function
w = new_watcher(test_option)
e = casbin.Enforcer(
get_examples("rbac_model.conf"), get_examples("rbac_policy.csv")
)
e.set_watcher(w)
# then the callback function will be called when the policy is updated.
e.save_policy()
Getting Help
License
This project is under Apache 2.0 License. See the LICENSE file for the full license text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for test_test782764782642-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe50bc328c202548b368fe4c2d562a2f2272a7e1a778148d73685298784d8413 |
|
MD5 | d531d2d64c71d3b07a337afb2fbd51d8 |
|
BLAKE2b-256 | 36996b02f4e2db85cce25c6a5cbaae24a643fccd718454df36d116cce1417109 |
Close
Hashes for test_test782764782642-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 941555f41172768762bbe7d6252ad6aa465f89f2a3f4b495616c9c2706a369bb |
|
MD5 | 7b5c5330c31527f64db6408aac6ee683 |
|
BLAKE2b-256 | a97d00374341484ef2b35e4b602688bf1f6ba5ae49e99958e39cc5e46fb6580b |