Casbin role watcher to be used for monitoring updates to policies for PyCasbin
Project description
redis-watcher
redis-watcher is the Redis watcher for pycasbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.
Installation
pip install casbin-redis-watcher
Simple Example
import os
import casbin
from casbin_redis_watcher import new_watcher, WatcherOptions
def callback_function(event):
print("update for remove filtered policy callback, event: {}".format(event))
def get_examples(path):
examples_path = os.path.split(os.path.realpath(__file__))[0] + "/../examples/"
return os.path.abspath(examples_path + path)
if __name__ == "main":
test_option = WatcherOptions()
test_option.host = "localhost"
test_option.port = "6379"
test_option.channel = "test"
test_option.ssl = False
test_option.optional_update_callback = callback_function
w = new_watcher(test_option)
e = casbin.Enforcer(
get_examples("rbac_model.conf"), get_examples("rbac_policy.csv")
)
e.set_watcher(w)
# then the callback function will be called when the policy is updated.
e.save_policy()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file casbin-redis-watcher-1.3.0.tar.gz.
File metadata
- Download URL: casbin-redis-watcher-1.3.0.tar.gz
- Upload date:
- Size: 364.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
957997766a449eda7f076d59c214d83445da2b9e454f12500413adfddcc5c410
|
|
| MD5 |
1aef247270400d18a9d4af9d21941826
|
|
| BLAKE2b-256 |
42737cd7269401a08514823da36877ad9bb41012e28f517500ead90ebcb0348d
|
File details
Details for the file casbin_redis_watcher-1.3.0-py3-none-any.whl.
File metadata
- Download URL: casbin_redis_watcher-1.3.0-py3-none-any.whl
- Upload date:
- Size: 399.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41aca4e8567c0f5af76f7f70bb12d582bfca7bdc809a9ba5005b42297c860f5f
|
|
| MD5 |
2d0f2b854264d7cdd0c267d7e5e7af4a
|
|
| BLAKE2b-256 |
3d2587f1eabcbae0a01b81b090a7304e1ce5ddd7ba59027848458d0349613c47
|