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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file casbin_async_postgres_watcher-1.4.0.tar.gz.
File metadata
- Download URL: casbin_async_postgres_watcher-1.4.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ace1e2b60f33913b1beab9f599772133a6c927140f094fe6f143a5bbe3ad19fc
|
|
| MD5 |
701c4885062ea86f5bc5032dc322c0fe
|
|
| BLAKE2b-256 |
c66b65ffefcc8332b1e43bb9d91c9cbe36a6183fd8b8a7d61a864481fba1cdee
|
File details
Details for the file casbin_async_postgres_watcher-1.4.0-py3-none-any.whl.
File metadata
- Download URL: casbin_async_postgres_watcher-1.4.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f50bec64676e2a94c9809938cf2bbe178213225bc7e0c2b0a74a473c75eb751
|
|
| MD5 |
1a477030a760e2b4f5a8fdfbf8e515c3
|
|
| BLAKE2b-256 |
66b51b04c17bc3847c89c327516e3830868373861e3c47b9016b1cae71c04ab3
|