Async PostgreSQL adapter for PyCasbin

Clone this repo:
  1. c92ac35 chore(release): 1.4.0 [skip ci] by semantic-release-bot · 7 months ago master v1.4.0
  2. c6e94e6 feat: fix README badges (#2) by Theo · 7 months ago
  3. 404f3d7 chore(release): 1.3.0 [skip ci] by semantic-release-bot · 7 months ago v1.3.0
  4. 8bc75bc feat: switch from casbin to pycasbin by Theo · 7 months ago
  5. d1656a7 chore(release): 1.2.0 [skip ci] by semantic-release-bot · 1 year, 4 months ago v1.2.0

async-postgres-watcher

tests PyPI - Version PyPI - Wheel PyPI - Downloads PyPI - License Discord

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.