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
casbin-redis-watcher-1.2.0.tar.gz
(331.5 kB
view details)
Built Distribution
File details
Details for the file casbin-redis-watcher-1.2.0.tar.gz
.
File metadata
- Download URL: casbin-redis-watcher-1.2.0.tar.gz
- Upload date:
- Size: 331.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 294d96a15c74c19fb60bfd737699f58c85121ff44065cb55028917e5ef21f40e |
|
MD5 | 193c521269bd89e99f43dcd311767bdd |
|
BLAKE2b-256 | f7b9631673f1f64da7a72efebcd7fd6a6553464f4a21b540ff4bbbf69fcc7568 |
File details
Details for the file casbin_redis_watcher-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: casbin_redis_watcher-1.2.0-py3-none-any.whl
- Upload date:
- Size: 361.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c37a4699d9dc72aed32da24825f65df6b549edf4e0c2cfdf3252ad4af60922ab |
|
MD5 | de0eb82d292cadbc5311a5b1952708a6 |
|
BLAKE2b-256 | 969a4ec17b4612c63c18023f85af1bad6047375714b64b7052ba461083eaf018 |