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
File details
Details for the file casbin-redis-watcher-1.1.1.tar.gz
.
File metadata
- Download URL: casbin-redis-watcher-1.1.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f0122ec67fde3985dbeca7e159a147292c137968ebe069a9570b4e386079e20 |
|
MD5 | dd100dccbd49d20d448d17f916326059 |
|
BLAKE2b-256 | 58cef42121d7c8ca7aba8efb6e954fc13e4dbafd20a177ceebee4f41efbab0cd |
File details
Details for the file casbin_redis_watcher-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: casbin_redis_watcher-1.1.1-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b1527523b2a8118e70e40bffe71069c144047a6fa0d361e3b91bd0a8c6b6e85 |
|
MD5 | 1c706d2cc1206195b369fd5ce5bb4da4 |
|
BLAKE2b-256 | 4af85405c9fb39a963fe273595c61c4619b669c9c01af56f08b498eceed51323 |