ormar Adapter for PyCasbin
Repo
GitHub
PyPI
ormar Adapter is the ormar adapter for PyCasbin. With this library, Casbin can load policy from ormar supported database or save policy to it.
Based on Officially Supported Databases, The current supported databases are:
- PostgreSQL
- MySQL
- SQLite
Installation
pip install ormar_casbin_adapter
or
poetry add ormar-casbin-adapter
Simple Example
import casbin
import databases
import ormar
from ormar_casbin_adapter import DatabasesAdapter
import sqlalchemy
database = Database("sqlite://", force_rollback=True)
metadata = sqlalchemy.MetaData()
class CasbinRule(ormar.Model):
class Meta:
database = database
metadata = metadata
tablename = "casbin_rules"
id: int = ormar.Integer(primary_key=True)
ptype: str = ormar.String(max_length=255)
v0: str = ormar.String(max_length=255)
v1: str = ormar.String(max_length=255)
v2: str = ormar.String(max_length=255, nullable=True)
v3: str = ormar.String(max_length=255, nullable=True)
v4: str = ormar.String(max_length=255, nullable=True)
v5: str = ormar.String(max_length=255, nullable=True)
adapter = DatabasesAdapter(model=CasbinRule)
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 data1ormar_casbin_adapter
pass
else:
# deny the request, show an error
pass
Getting Help
License
This project is licensed under the Apache 2.0 license.
Metadata
Release files for ormar-casbin-adapter 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ormar-casbin-adapter-0.0.2.tar.gz | 8.5 kB | Without provenance | Details for ormar-casbin-adapter-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ormar_casbin_adapter-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for ormar_casbin_adapter-0.0.2-py3-none-any.whl |
Total release size: 20.6 kB
Release files / ormar-casbin-adapter-0.0.2.tar.gz
| Download URL | ormar-casbin-adapter-0.0.2.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18e49ceb2f0546cf80a21b0b01648c6edd50d9de76032e0ae90676a71796ac3f
|
|
BLAKE2b-256 checksum How to use checksums |
54f8ed934a14c9472fcd14dbeef0bd381dd48592807f99ba7a0b3bc671dd5f10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
|
Release files / ormar_casbin_adapter-0.0.2-py3-none-any.whl
| Download URL | ormar_casbin_adapter-0.0.2-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4511b89540d24a5b32f67683bc59f557e61e9e512f3e6f0846bd63c80a20a2cb
|
|
BLAKE2b-256 checksum How to use checksums |
48be8153f9c540538f6a2fadca9d7aa2e583f45c7458e72ee820e258c1f14d72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
|
Security for ormar-casbin-adapter 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.