Skip to main content

Async casbin role watcher to be used for monitoring updates to policies for PyCasbin

Project description

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.

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

casbin_async_postgres_watcher-1.4.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

casbin_async_postgres_watcher-1.4.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file casbin_async_postgres_watcher-1.4.0.tar.gz.

File metadata

File hashes

Hashes for casbin_async_postgres_watcher-1.4.0.tar.gz
Algorithm Hash digest
SHA256 ace1e2b60f33913b1beab9f599772133a6c927140f094fe6f143a5bbe3ad19fc
MD5 701c4885062ea86f5bc5032dc322c0fe
BLAKE2b-256 c66b65ffefcc8332b1e43bb9d91c9cbe36a6183fd8b8a7d61a864481fba1cdee

See more details on using hashes here.

File details

Details for the file casbin_async_postgres_watcher-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_async_postgres_watcher-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f50bec64676e2a94c9809938cf2bbe178213225bc7e0c2b0a74a473c75eb751
MD5 1a477030a760e2b4f5a8fdfbf8e515c3
BLAKE2b-256 66b51b04c17bc3847c89c327516e3830868373861e3c47b9016b1cae71c04ab3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page