Skip to main content

MongoDB watcher for PyCasbin that enables distributed policy synchronization using MongoDB change streams

Project description

PyCasbin MongoDB Watcher

MongoDB watcher for PyCasbin. It enables distributed policy synchronization across multiple Casbin instances using MongoDB Change Streams.

Installation

pip install pycasbin-mongo-watcher

Quick Start

import casbin
from mongo_watcher import new_watcher

# Reload policy on updates
def on_update():
    enforcer.load_policy()

# Create MongoDB watcher
watcher = new_watcher(
    dsn="mongodb://localhost:27017",
    db_name="casbin",
    collection="casbin_watcher",
)
watcher.set_update_callback(on_update)

# Initialize Casbin enforcer
enforcer = casbin.Enforcer("path/to/model.conf", "path/to/policy.csv")
# Bind watcher to enforcer
enforcer.set_watcher(watcher)

License

Apache-2.0. See LICENSE.

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

pycasbin_mongo_watcher-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

pycasbin_mongo_watcher-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pycasbin_mongo_watcher-0.1.0.tar.gz.

File metadata

  • Download URL: pycasbin_mongo_watcher-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pycasbin_mongo_watcher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5de503265caaaf1dc5240b39084dea0906bba7d7529004d93bdede0ad2aabc20
MD5 368ef9958b0cd7d7aa243d54997cb8c1
BLAKE2b-256 3df91fda75ae4802913fe7a3d1fd88364cf7f833b5f1523c8b615909455b78e7

See more details on using hashes here.

File details

Details for the file pycasbin_mongo_watcher-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pycasbin_mongo_watcher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3972bb09e8cfdde16f27e8462014dd25052a393dca1dc61d6d0183199df43bff
MD5 38ef7a232dfd89614d58da92afa60c28
BLAKE2b-256 99ab4f24466eae8b72d0145a7e15d846b663e208f060f9c7d476e789e2e75da9

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