https://github.com/officialpycasbin/async-postgres-watcher
Async PostgreSQL adapter for PyCasbin
https://github.com/officialpycasbin/async-postgres-watcher
abac acl adapter async auth authz casbin database db postgres postgresql py pycasbin python rbac
Last synced: 5 months ago
JSON representation
Async PostgreSQL adapter for PyCasbin
- Host: GitHub
- URL: https://github.com/officialpycasbin/async-postgres-watcher
- Owner: officialpycasbin
- License: apache-2.0
- Created: 2024-11-12T02:51:54.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-08-20T05:19:34.000Z (11 months ago)
- Last Synced: 2026-01-04T15:11:46.477Z (6 months ago)
- Topics: abac, acl, adapter, async, auth, authz, casbin, database, db, postgres, postgresql, py, pycasbin, python, rbac
- Language: Python
- Homepage: https://github.com/casbin/pycasbin
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# async-postgres-watcher
[](https://github.com/officialpycasbin/async-postgres-watcher/actions)
[](https://pypi.org/project/casbin-async-postgres-watcher/)
[](https://pypi.org/project/casbin-async-postgres-watcher/)
[](https://pypi.org/project/casbin-async-postgres-watcher/)
[](https://pypi.org/project/casbin-async-postgres-watcher/)
[](https://discord.gg/S5UjpzGZjN)
Async Casbin PostgreSQL watcher to be used for monitoring updates to Casbin policies.
## Installation
```bash
pip install casbin-async-postgres-watcher
```
## Basic Usage Example
### With Flask-authz
```python
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](https://magicstack.github.io/asyncpg/current/api/index.html#connection) for full details of SSL parameters.
### With Flask-authz
```python
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
- [PyCasbin](https://github.com/casbin/pycasbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.