etcd watcher for PyCasbin

Clone this repo:
  1. 26a0039 chore(release): 1.5.0 [skip ci] by semantic-release-bot · 7 months ago master v1.5.0
  2. 7d3cde9 feat: fix README badges (#3) by Theo · 7 months ago
  3. b90243a chore(release): 1.4.0 [skip ci] by semantic-release-bot · 7 months ago v1.4.0
  4. e015155 feat: upgrade semantic-release-pypi to fix the release error (#2) by Theo · 7 months ago
  5. a3664b3 chore(release): 1.3.0 [skip ci] by semantic-release-bot · 7 months ago v1.3.0

etcd-watcher

tests Coverage Status Version PyPI - Wheel Pyversions Download Discord

Etcd Watcher is the Etcd watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.

Installation

pip install etcd-watcher

Simple Example

import casbin
from etcd_watcher import new_watcher

def update_callback_func(event):
    ...

watcher = new_watcher(endpoints=["localhost", 2379], keyname="/casbin")
watcher.set_update_callback(update_callback_func)

e = casbin.Enforcer(
	get_examples("rbac_model.conf"), get_examples("rbac_policy.csv")
)

e.set_watcher(watcher)
# update_callback_func will be called
e.save_policy()

Getting Help

License

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