Async casbin role watcher to be used for monitoring updates to policies for PyCasbin
Project description
async-postgres-watcher
Async Casbin PostgreSQL watcher to be used for monitoring updates to Casbin policies.
Installation
pip install casbin-async-postgres-watcher
Basic Usage Example
With Flask-authz
from flask_authz import CasbinEnforcer
from async_postgres_watcher import AsyncPostgresWatcher
from flask import Flask
from casbin.persist.adapters import FileAdapter
casbin_enforcer = CasbinEnforcer(app, adapter)
watcher = AsyncPostgresWatcher(host=HOST, port=PORT, user=USER, password=PASSWORD, dbname=DBNAME)
watcher.set_update_callback(casbin_enforcer.e.load_policy)
casbin_enforcer.set_watcher(watcher)
Basic Usage Example With SSL Enabled
See asyncpg documentation for full details of SSL parameters.
With Flask-authz
from flask_authz import CasbinEnforcer
from async_postgres_watcher import AsyncPostgresWatcher
from flask import Flask
from casbin.persist.adapters import FileAdapter
casbin_enforcer = CasbinEnforcer(app, adapter)
# If check_hostname is True, the SSL context is created with sslmode=verify-full.
# If check_hostname is False, the SSL context is created with sslmode=verify-ca.
watcher = AsyncPostgresWatcher(host=HOST, port=PORT, user=USER, password=PASSWORD, dbname=DBNAME, sslrootcert=SSLROOTCERT, check_hostname = True, sslcert=SSLCERT, sslkey=SSLKEY)
watcher.set_update_callback(casbin_enforcer.e.load_policy)
casbin_enforcer.set_watcher(watcher)
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 casbin-async-postgres-watcher-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | be6b0eab7af75aa42c70e1beb8cea5217d647380354250e412fbe3089f8fb7cc |
|
MD5 | bcf832b7c484d0b78e14705e243d9255 |
|
BLAKE2b-256 | e341f7f07836083e6728dbc54224cb3a538458bed716e40368fcb1dc7b2ad493 |
Close
Hashes for casbin_async_postgres_watcher-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dabecb7cb7e6428f3250a532f8ff16fa9a165cd73f3b195aad01bad6f9b62174 |
|
MD5 | 106f90f5f3c6962a20cf5799b8e63655 |
|
BLAKE2b-256 | 745fd23de01972594d36a9ffbbc1d4beb3784f6070e39aa3f04ebc2cbedbfc8b |