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
File details
Details for the file casbin-async-postgres-watcher-1.1.0.tar.gz
.
File metadata
- Download URL: casbin-async-postgres-watcher-1.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be6b0eab7af75aa42c70e1beb8cea5217d647380354250e412fbe3089f8fb7cc |
|
MD5 | bcf832b7c484d0b78e14705e243d9255 |
|
BLAKE2b-256 | e341f7f07836083e6728dbc54224cb3a538458bed716e40368fcb1dc7b2ad493 |
File details
Details for the file casbin_async_postgres_watcher-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: casbin_async_postgres_watcher-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dabecb7cb7e6428f3250a532f8ff16fa9a165cd73f3b195aad01bad6f9b62174 |
|
MD5 | 106f90f5f3c6962a20cf5799b8e63655 |
|
BLAKE2b-256 | 745fd23de01972594d36a9ffbbc1d4beb3784f6070e39aa3f04ebc2cbedbfc8b |