Skip to main content

PyMongo Adapter for PyCasbin

Project description

PyMongo Adapter for PyCasbin

Build Status Coverage Status Version PyPI - Wheel Pyversions Download License

PyMongo Adapter is the PyMongo adapter for PyCasbin. With this library, Casbin can load policy from MongoDB or save policy to it.

Installation

pip install casbin_pymongo_adapter

Simple Example

import casbin_pymongo_adapter
import casbin

adapter = casbin_pymongo_adapter.Adapter('mongodb://localhost:27017/', "dbname")

e = casbin.Enforcer('path/to/model.conf', adapter, True)

sub = "alice"  # the user that wants to access a resource.
obj = "data1"  # the resource that is going to be accessed.
act = "read"  # the operation that the user performs on the resource.

if e.enforce(sub, obj, act):
    # permit alice to read data1casbin_sqlalchemy_adapter
    pass
else:
    # deny the request, show an error
    pass

Getting Help

License

This project is licensed under the Apache 2.0 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

casbin_pymongo_adapter-1.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

casbin_pymongo_adapter-1.1.0-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file casbin_pymongo_adapter-1.1.0.tar.gz.

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.1.0.tar.gz
Algorithm Hash digest
SHA256 03ea6f7b1cdf7d82b0de7c942f976fdaa867e08037ab931b009b53bcaa9ee2cd
MD5 4c50e4dff9d82ee1b7dd87cac9428d47
BLAKE2b-256 6c8dd816e8a3042511b70bf116e225b7bd15a3379c8b6717ad8468e64646e600

See more details on using hashes here.

File details

Details for the file casbin_pymongo_adapter-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 864c84265332facb46d41987fb441aebdb884730ec9158642e0976901116549f
MD5 c1eab2fd66baea92f8e746653062d4ad
BLAKE2b-256 138c2adc0bef41067a6e69adae569b748830d04db3033c4d542ff88e3835e495

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