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

Uploaded Source

Built Distribution

casbin_pymongo_adapter-1.0.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.0.0.tar.gz.

File metadata

  • Download URL: casbin_pymongo_adapter-1.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for casbin_pymongo_adapter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ffefe0357e1737e136790a09034502f528eec6487bcb80796c14cf79e3b7642e
MD5 83e7b86eb6fa090c2449441991f2195b
BLAKE2b-256 aced515b46dd6164ac2b98948988612bcd315f2af01ee0376f233543a5f90a5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: casbin_pymongo_adapter-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for casbin_pymongo_adapter-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 070b611b149ac91623fbf32456be8f84f34719c878c7736802f054af83ee642c
MD5 05bdbb4078e57d0d1b4cce6e9265ba7e
BLAKE2b-256 556a361a3281a057a12711175f0cc1e8731d225f0b535ace3965cb2d875c29ae

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