RabbitMQ Watcher for PyCasbin

Clone this repo:
  1. bb93037 chore(release): 1.7.0 [skip ci] by semantic-release-bot · 7 months ago master v1.7.0
  2. d2785ab feat: fix README badges (#3) by Theo · 7 months ago
  3. 4ae4056 chore(release): 1.6.0 [skip ci] by semantic-release-bot · 7 months ago v1.6.0
  4. 84ae32e feat: switch from casbin to pycasbin (#2) by Theo · 7 months ago
  5. 9ef58b0 chore(release): 1.5.0 [skip ci] by semantic-release-bot · 1 year, 1 month ago v1.5.0

rabbitmq-watcher

Build Status Coverage Status Version PyPI - Wheel Pyversions Download Discord

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

Installation

pip install casbin-rabbitmq-watcher

Simple Example

import os

import casbin
from casbin_rabbitmq_watcher import new_watcher


def get_examples(path):
    examples_path = os.path.split(os.path.realpath(__file__))[0] + "/../examples/"
    return os.path.abspath(examples_path + path)


def update_callback_func(msg):
    ...


watcher = new_watcher()
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.