/postgresql-watcher

PostgreSQL Watcher for PyCasbin

Primary LanguagePythonApache License 2.0Apache-2.0

postgresql-watcher

tests Coverage Status Version PyPI - Wheel Download Gitter

Casbin role watcher to be used for monitoring updates to casbin policies

Installation

pip install casbin-postgresql-watcher

Basic Usage Example

With Flask-authz

from flask_authz import CasbinEnforcer
from postgresql_watcher import PostgresqlWatcher
from flask import Flask
from casbin.persist.adapters import FileAdapter

casbin_enforcer = CasbinEnforcer(app, adapter)
watcher = PostgresqlWatcher(host=HOST, port=PORT, user=USER, password=PASSWORD)
watcher.set_update_callback(casbin_enforcer.e.load_policy())
casbin_enforcer.set_watcher(watcher)