chore(release): 1.0.0 [skip ci] # 1.0.0 (2024-03-16) ### Features * add GitHub Actions CI and semantic-release ([#4](https://github.com/pycasbin/async-postgres-watcher/issues/4)) ([bd150f5](https://github.com/pycasbin/async-postgres-watcher/commit/bd150f581a7a681da4daacc11cfbbb14b1207a22)), closes [#3](https://github.com/pycasbin/async-postgres-watcher/issues/3) [#1](https://github.com/pycasbin/async-postgres-watcher/issues/1) * add initial code ([#2](https://github.com/pycasbin/async-postgres-watcher/issues/2)) ([6c868e1](https://github.com/pycasbin/async-postgres-watcher/commit/6c868e108e8b68e6aacde833a4afe96f75345fe8)), closes [#1](https://github.com/pycasbin/async-postgres-watcher/issues/1) * Update README.md ([9fdb4ab](https://github.com/pycasbin/async-postgres-watcher/commit/9fdb4ab4563ea2dd2a456cdbac614657ebf50c75))
Async Casbin PostgreSQL watcher to be used for monitoring updates to Casbin policies.
pip install casbin-async-postgres-watcher
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)
See asyncpg documentation for full details of SSL parameters.
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)
This project is under Apache 2.0 License. See the LICENSE file for the full license text.