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

Uploaded Source

Built Distribution

redis_watcher-1.6.0-py3-none-any.whl (403.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: redis_watcher-1.6.0.tar.gz
  • Upload date:
  • Size: 368.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for redis_watcher-1.6.0.tar.gz
Algorithm Hash digest
SHA256 251828e304b1ec582188303080565c543e6abe0eff2bd0d3d54094d0bd0e4401
MD5 d4307f3a0849f1985f9dca5c39b1a289
BLAKE2b-256 0d18dbab2021e5e4fc717b67e24611e3fae77516adefd98b132dbf23f1ac5927

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redis_watcher-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 403.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for redis_watcher-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a54adc8877541df352a2d280c321f23d279e45db04a355fad5705daec5946a
MD5 f9fb1a5657a7b8b45e995782a14cdfcd
BLAKE2b-256 b6961826ffba2639dbfdb4dd61f8225667ec965080a864f15443ef7173073008

See more details on using hashes here.

Supported by

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