Skip to main content

Casbin role watcher to be used for monitoring updates to policies for PyCasbin

Project description

redis-watcher

GitHub Action Coverage Status Version PyPI - Wheel Pyversions Download Discord

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


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.4.0.tar.gz (367.3 kB view details)

Uploaded Source

Built Distribution

redis_watcher-1.4.0-py3-none-any.whl (402.2 kB view details)

Uploaded Python 3

File details

Details for the file redis_watcher-1.4.0.tar.gz.

File metadata

  • Download URL: redis_watcher-1.4.0.tar.gz
  • Upload date:
  • Size: 367.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for redis_watcher-1.4.0.tar.gz
Algorithm Hash digest
SHA256 7faa9291252ba67c600b0f84142c71435ae2e70e5de24d7e92eb155188fe9ef8
MD5 dbd7107a9b4707e1361e5e9c9612abbc
BLAKE2b-256 b85baf9eaadb12328a2a6b0a615076bf695f7894072691a6b0cbab408a266149

See more details on using hashes here.

File details

Details for the file redis_watcher-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for redis_watcher-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bed02c7a23ad26e49c291b091ce337dc3c5415238c869ea992c180f3f9b2abfe
MD5 d1fa0dee4442c5b2146f6afc80902d5f
BLAKE2b-256 4d5039190e20b167dd3008019c98ff79459dd563fad8df54ad6e817793fa170c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page