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.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3283abe2796183335ceec061a98f2b4f13b75102033a0663ce26e808cbbcc67 |
|
MD5 | 700b110a503c0e24e15cadedce3c9fbe |
|
BLAKE2b-256 | df22ca34c65a50066a694259078d1b238df0e5568cd0b8f1ee7745be458a2212 |
Close
Hashes for test_test782764782642-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38df126d1b8940603d8cc7f6559229e3f3313cab7b859857b8bfbb0f2da087e0 |
|
MD5 | 25cf7d9e1c5541a4f8c1c9aa133f0ff4 |
|
BLAKE2b-256 | 609f378943b81c02989139ec8e51067e2d9846ca57d6f0b1d75f7b2776edc577 |