Django's ORM adapter for PyCasbin
Project description
Django ORM Adapter for PyCasbin
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for casbin-django-orm-adapter-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a355a9ae3d98fea46769782a0845cf63f68ced5e7e2afc2734002e898d6538fa |
|
MD5 | e405c1db21bddae07eac42387b8eaf3a |
|
BLAKE2b-256 | 3a5b0647d166ece5577453417c2a6b8f49a48c7fec81c1dedc0388713e88595c |
Close
Hashes for casbin_django_orm_adapter-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a63d7c87b12102ffffa18dae7b5a94584bfa872db7555a2f0ad9da2a07178f5 |
|
MD5 | 7ccb2264c3699f6fc83ff5a5761f1ff1 |
|
BLAKE2b-256 | 84c533dea30ec87a6e02b259bc5b9fabbae9b2d0345d639d07d461a2db436c13 |