Casbin角色监视器,用于监视PyCasbin策略的更新
项目描述
redis-watcher
redis-watcher是Redis监视器,用于pycasbin。使用此库,Casbin可以在多个执行器实例中同步策略与数据库。
安装
pip install casbin-redis-watcher
简单示例
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.ssl = False
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()
获取帮助
许可证
此项目采用Apache 2.0许可证。有关完整的许可证文本,请参阅LICENSE文件。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
casbin-redis-watcher-1.3.0.tar.gz (364.3 kB 查看哈希值)
构建分发
casbin_redis_watcher-1.3.0-py3-none-any.whl (399.2 kB 查看哈希值)