https://github.com/pycasbin/redis-watcher
Redis watcher for PyCasbin
https://github.com/pycasbin/redis-watcher
abac acl auth authorization authz casbin permission pycasbin python rbac redis watcher
Last synced: about 1 month ago
JSON representation
Redis watcher for PyCasbin
- Host: GitHub
- URL: https://github.com/pycasbin/redis-watcher
- Owner: pycasbin
- License: apache-2.0
- Created: 2021-04-16T09:12:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-29T11:14:32.000Z (over 1 year ago)
- Last Synced: 2025-07-30T04:35:18.250Z (2 months ago)
- Topics: abac, acl, auth, authorization, authz, casbin, permission, pycasbin, python, rbac, redis, watcher
- Language: Python
- Homepage: https://github.com/casbin/pycasbin
- Size: 29.3 KB
- Stars: 10
- Watchers: 1
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-watcher
[](https://github.com/pycasbin/redis-watcher/actions)
[](https://coveralls.io/github/pycasbin/redis-watcher)
[](https://pypi.org/project/casbin-redis-watcher/)
[](https://pypi.org/project/casbin-redis-watcher/)
[](https://pypi.org/project/casbin-redis-watcher/)
[](https://pypi.org/project/casbin-redis-watcher/)
[](https://discord.gg/S5UjpzGZjN)redis-watcher is the [Redis](https://github.com/redis/redis) watcher for [pycasbin](https://github.com/casbin/pycasbin). With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.
## Installation
pip install casbin-redis-watcher
## Simple Example
```python
import os
import casbin
from casbin_redis_watcher import new_watcher, WatcherOptionsdef 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
- [pycasbin](https://github.com/casbin/pycasbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.