Skip to main content

Django's ORM adapter for PyCasbin

Project description

Django ORM Adapter for PyCasbin

Build Status Coverage Status Version PyPI - Wheel Pyversions Download License

Django ORM Adapter is the Django's ORM adapter for PyCasbin. With this library, Casbin can load policy from Django ORM supported database or save policy to it.

Based on Officially Supported Databases, The current supported databases are:

  • PostgreSQL
  • MariaDB
  • MySQL
  • Oracle
  • SQLite
  • IBM DB2
  • Microsoft SQL Server
  • Firebird
  • ODBC

Installation

pip install casbin_django_orm_adapter

Add casbin_adapter to your INSTALLED_APPS

INSTALLED_APPS = [
    ...
    'casbin_adapter',
    ...
]

To run schema migration, execute `python manage.py migrate casbin_adapter

Simple Example

import casbin
from casbin_adapter.adapter import Adapter

adapter = Adapter()

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_django_orm_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-django-orm-adapter-0.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

casbin_django_orm_adapter-0.0.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file casbin-django-orm-adapter-0.0.1.tar.gz.

File metadata

  • Download URL: casbin-django-orm-adapter-0.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for casbin-django-orm-adapter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a355a9ae3d98fea46769782a0845cf63f68ced5e7e2afc2734002e898d6538fa
MD5 e405c1db21bddae07eac42387b8eaf3a
BLAKE2b-256 3a5b0647d166ece5577453417c2a6b8f49a48c7fec81c1dedc0388713e88595c

See more details on using hashes here.

File details

Details for the file casbin_django_orm_adapter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: casbin_django_orm_adapter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for casbin_django_orm_adapter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a63d7c87b12102ffffa18dae7b5a94584bfa872db7555a2f0ad9da2a07178f5
MD5 7ccb2264c3699f6fc83ff5a5761f1ff1
BLAKE2b-256 84c533dea30ec87a6e02b259bc5b9fabbae9b2d0345d639d07d461a2db436c13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page