Flask-Casbin-Redis-Watcher
Casbin role watcher to be used for monitoring updates to casbin policies
Installation
pip install flask-casbin-redis-watcher
Basic Usage
from flask_casbin import CasbinEnforcer
from flask_casbin_redis_watcher import RedisWatcher
casbin_enforcer = CasbinEnforcer(app, adapter)
watcher=RedisWatcher(redis_hostname, redis_port)
watcher.set_update_callback(casbin_enforcer.e.load_policy)
casbin_enforcer.set_watcher(watcher)
Using alongside UWSGI
This redis-watcher module starts separate processes which subscribe to a redis channel, and listens for updates to the casbin policy on that channel. When running within WSGI contexts (like uwsgi) you may want to start these processes as a postfork action. As is depicted below:
try:
from uwsgidecorators import postfork
print("Running in uwsgi context")
except ModuleNotFoundError:
print("Not running in uwsgi context")
postfork = None
if postfork:
@postfork
def load_watcher():
global casbin_enforcer
watcher = RedisWatcher(redis_info.hostname, redis_info.port)
watcher.set_update_callback(casbin_enforcer.e.load_policy)
casbin_enforcer.set_watcher(watcher)
Metadata
Release files for flask-casbin-redis-watcher 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_casbin_redis_watcher-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for flask_casbin_redis_watcher-0.1.0-py3-none-any.whl |
Release files / flask_casbin_redis_watcher-0.1.0-py3-none-any.whl
| Download URL | flask_casbin_redis_watcher-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4decec2431c91459f9225dbbf4217dbc63ee855882575eca8c694efbe1c2a2c
|
|
BLAKE2b-256 checksum How to use checksums |
263ffc801ad656bb83972a802f725400dc999e01108973ba7993093cbd358cdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.7.2
|
Security for flask-casbin-redis-watcher 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.