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

Uploaded Source

Built Distribution

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

redis_watcher-1.7.0-py3-none-any.whl (403.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for redis_watcher-1.7.0.tar.gz
Algorithm Hash digest
SHA256 873254416d4ebe595cc6c23a29c7dfee96243d98dcf7315d9a025a84bbb397b4
MD5 65da19598bf41f924b8db665a6e2e019
BLAKE2b-256 1d7287203799b44ecc1add75ecacdb9f03e176fb67f99740efed051ae617ae37

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for redis_watcher-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7db7ff2aadbeec5dd41208e0219b068592ebb2551884bf48ed430891583f9d48
MD5 57d775fe2e66aa06e8cb27e67cd32e38
BLAKE2b-256 14fdbce54fe714f28301cc6bb6939647ecb12249b1ca8772cb0b72af846a20b0

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