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

Uploaded Source

Built Distribution

casbin_pymongo_adapter-1.2.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.2.0.tar.gz.

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.2.0.tar.gz
Algorithm Hash digest
SHA256 376256de1e210ab4ef97bfa00c7af255ef54648ea78eff5da5e5627bdc96b47d
MD5 0146f8374686b2bcfdb0ae5b658f16b3
BLAKE2b-256 43ff09138595b3e68d2bb216f456f4b82cff34f43d1af04aea6a2ab6eab31bac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 38955cb928d93d6b9f83a5d05c8e1238cb20c36ea460183c373efe805fc8e995
MD5 feb8d5a6e056e16dde7619aff76fa581
BLAKE2b-256 a4b297d744e2a381a8c3d0f43c71b163c9a56964e546c9e6e51a805153d2930b

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