varco-casbin
Casbin policy-engine authorization backend for varco — ACL, RBAC, and ABAC
with dynamic, persisted policies and a ready-made REST management router.
varco_casbin implements the backend-agnostic policy seam defined in
varco_core.auth.policy:
varco_core.auth.PolicyEngine ← enforce(request) hot path
varco_core.auth.PolicyManagement ← add/remove/list rules + role assignments
↑ both implemented by
varco_casbin.CasbinPolicyEngine ← wraps casbin.AsyncEnforcer
↑ bridged into the service layer by
varco_core.auth.PolicyEngineAuthorizer (opt-in via CasbinAuthorizationConfiguration)
↑ administered over REST by
varco_casbin.CasbinPolicyRouter ← varco_fastapi GenericRouter (requires the [fastapi] extra)
Install
pip install varco-casbin # engine only (in-memory / file policies)
pip install "varco-casbin[sqlalchemy]" # + durable SQL-backed policy store
pip install "varco-casbin[beanie]" # + durable MongoDB-backed policy store (Beanie)
pip install "varco-casbin[fastapi]" # + REST management router
Quick start (DI)
from providify import DIContainer
from varco_casbin.di import bootstrap, enable_policy_authorizer
from varco_core.auth import PolicyEngine, PolicyManagement, AbstractAuthorizer
container = bootstrap(DIContainer()) # scans the engine + settings
enable_policy_authorizer(container) # opt-in: bind the authorizer
engine: PolicyEngine = await container.aget(PolicyEngine)
mgmt: PolicyManagement = await container.aget(PolicyManagement)
await mgmt.add_role_for_user("alice", "admin") # g, alice, admin
await mgmt.add_policy("admin", "*", "*") # p, admin, *, *
Configuration
All settings read from VARCO_CASBIN_* env vars (see CasbinSettings):
| Env var | Default | Meaning |
|---|---|---|
VARCO_CASBIN_MODEL_PRESET |
rbac |
acl / rbac / rbac_domains / abac |
VARCO_CASBIN_MODEL_PATH |
— | explicit .conf model file (overrides preset) |
VARCO_CASBIN_ADAPTER |
memory |
memory / file / sqlalchemy / beanie |
VARCO_CASBIN_DB_URL |
— | SQLAlchemy URL for sqlalchemy, or Mongo URL for beanie |
VARCO_CASBIN_DB_NAME |
— | MongoDB database name — required for adapter=beanie |
VARCO_CASBIN_POLICY_PATH |
— | CSV path for the file adapter |
VARCO_CASBIN_ADMIN_ROLE |
admin |
role the REST router requires by default |
memory is non-durable (dev/test only); file is single-process (concurrent writers can
corrupt the CSV); sqlalchemy and beanie both support dynamic, durable, concurrent CRUD —
pick whichever matches the rest of your persistence stack.
REST management
Mount build_policy_router(...) (requires [fastapi]) to administer policies and
role assignments over REST — all endpoints guarded by require_roles(admin_role):
from varco_casbin.router import build_policy_router
app.include_router(build_policy_router(engine, server_auth=auth)) # engine = CasbinPolicyEngine
GET/POST/DELETE /authz/policies # p-rules
GET/POST/DELETE /authz/roles # g-rules (role assignments)
POST /authz/check # test an enforcement decision
POST /authz/reload # reload from the durable store
See the varco docs (technical_docs/features/casbin-authorization.md) for the
full guide, including the ABAC example.
Metadata
Release files for varco-casbin 3.2.0
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 |
|---|---|---|---|---|
| varco_casbin-3.2.0.tar.gz | 61.3 kB | With provenance | Details for varco_casbin-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| varco_casbin-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for varco_casbin-3.2.0-py3-none-any.whl |
Total release size: 111.0 kB
Release files / varco_casbin-3.2.0.tar.gz
| Download URL | varco_casbin-3.2.0.tar.gz |
|---|---|
| Size | 61.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b54cddcff263b51793d650d38bf069fd5fd5a64e2e9d771d32ea42604b08619
|
|
BLAKE2b-256 checksum How to use checksums |
272402d0647822c743e5100616e23db158e247108606bbd9fe7080c53c12cecf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logRelease files / varco_casbin-3.2.0-py3-none-any.whl
| Download URL | varco_casbin-3.2.0-py3-none-any.whl |
|---|---|
| Size | 49.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68c91c4fd448d206980d36701b22d20f587b07d20fff6bc7450fac2dd0114778
|
|
BLAKE2b-256 checksum How to use checksums |
a6f469d74d4cc5a5ae6affa0c93c14b056562238f9deaf9ea925aa9894d5a54e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logSecurity for varco-casbin 3.2.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for varco_casbin-3.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logA 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.