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.2.0.tar.gz
.
File metadata
- Download URL: casbin_async_postgres_watcher-1.2.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 883fbb112753c73402b1cbb0bf1d13d106470d4a373ad27e4c2b2a84a66d4ea3 |
|
MD5 | 140d372bf88df9ba1508fe8e4f1a5deb |
|
BLAKE2b-256 | 6fde1854545a45b07e10966ff586019d0a53a47d024ed329ff0f531276975af0 |
File details
Details for the file casbin_async_postgres_watcher-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: casbin_async_postgres_watcher-1.2.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b1a096ce0ad30202c4f24c7848f0de142b8dedae9950257e0f8f70bcc4c2035 |
|
MD5 | 8898a0ecd49060747c798be6482aba63 |
|
BLAKE2b-256 | 58ebcc56da9594fe5cd403d1acdf98a45e1939b92a0c470556761b19a6796347 |