Skip to main content

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

casbin_redis_watcher-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file casbin-redis-watcher-1.0.0.tar.gz.

File metadata

  • Download URL: casbin-redis-watcher-1.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.13

File hashes

Hashes for casbin-redis-watcher-1.0.0.tar.gz
Algorithm Hash digest
SHA256 defe12ac834288390050d0149ef76cacc63fab5eb0ceb7528203d37a46fda727
MD5 b14a770f39d2059d890488fb555c00de
BLAKE2b-256 27137d6d34f3fe85b3d716907bdad7be394d18bf4739692cefd2788b57a21afe

See more details on using hashes here.

File details

Details for the file casbin_redis_watcher-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_redis_watcher-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c08d938a477cec42f049b700832b11932563df960b0dbe0780e817b676310883
MD5 c51dc6bf4f6404f6de100aa64a8039c9
BLAKE2b-256 8a46188508d3314917808009bd3398cf1a07e6cb12ec39a726cbfe8ae7fb469d

See more details on using hashes here.

Supported by

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