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 redis-watcher
Simple Example
import os
import casbin
from 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis_watcher-1.3.0.tar.gz
(4.2 MB
view details)
Built Distribution
File details
Details for the file redis_watcher-1.3.0.tar.gz
.
File metadata
- Download URL: redis_watcher-1.3.0.tar.gz
- Upload date:
- Size: 4.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cf5ec77bb2163c7fcccf5f43cc76b662343c42daf46763a1a161c02dc6faa68 |
|
MD5 | 3d219e7d2dc21f2d0cad7197d5723cd8 |
|
BLAKE2b-256 | 7c99e5b207fe164a2e6b71651081426e7189fffee3c45c559c11d95a2e2676cc |
File details
Details for the file redis_watcher-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: redis_watcher-1.3.0-py3-none-any.whl
- Upload date:
- Size: 5.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 098903da01c3762f26f6924a12b7327d1244ec765d688c9562516d9d061dd7df |
|
MD5 | 8dc74e9c4a7443886016c37c0a49059c |
|
BLAKE2b-256 | 5bb2ecd500cbd6175522b330592895e0ebe7d773152833ee4bc93d997288dd37 |