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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf0a6a7df1c5fcfd4923fb0daa1daef3d4cf8880da2d75ab3eae7902ff871ca1 |
|
MD5 | 2167f03339ea007c7fcdf1d9a0b7dcf7 |
|
BLAKE2b-256 | 6c06cfb44c9ef9c8c1ada07306c5c5931f5e3822f0c3d58b350401adc5c4532a |
Close
Hashes for test_test782764782642-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 059bf639268572270847b3c4e47b3ca71434899e751ce2b0bd9b6307a9427534 |
|
MD5 | 4ac4509f9599937f4a0a2b2b41c4eb33 |
|
BLAKE2b-256 | 6be7908734c286efb572d5e7c3b5e47d7a9426b8716cf639bba77b3e7457c928 |