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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file varco_casbin-3.0.0.tar.gz.
File metadata
- Download URL: varco_casbin-3.0.0.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e809c8553005e87f59c98e3a28ab758deb396e7e442b823bf7aab974c416a25
|
|
| MD5 |
2a46c877ba2ed695759b4cb45873afc3
|
|
| BLAKE2b-256 |
07a73c1aa15c893042f2f0b31b222892702938c230fb5e549b370f23ca61d058
|
Provenance
The following attestation bundles were made for varco_casbin-3.0.0.tar.gz:
Publisher:
release.yml on edoardoscarpaci/varco
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varco_casbin-3.0.0.tar.gz -
Subject digest:
5e809c8553005e87f59c98e3a28ab758deb396e7e442b823bf7aab974c416a25 - Sigstore transparency entry: 2666789971
- Sigstore integration time:
-
Permalink:
edoardoscarpaci/varco@79498d3cf3e15d089fc8059a2497b364d1dbe7b6 -
Branch / Tag:
refs/tags/v3.0.0rc1 - Owner: https://github.com/edoardoscarpaci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@79498d3cf3e15d089fc8059a2497b364d1dbe7b6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file varco_casbin-3.0.0-py3-none-any.whl.
File metadata
- Download URL: varco_casbin-3.0.0-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73c3793d731951d6def94f8b4f3bb453e8ec84544b6f1745878e20e53a1f7203
|
|
| MD5 |
9b17a631d6efb70e0c4725e032a8b74e
|
|
| BLAKE2b-256 |
7a91f938235bbd63a61000243d76720bde25113e1a4af6a76fb1d229e089dc7d
|
Provenance
The following attestation bundles were made for varco_casbin-3.0.0-py3-none-any.whl:
Publisher:
release.yml on edoardoscarpaci/varco
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varco_casbin-3.0.0-py3-none-any.whl -
Subject digest:
73c3793d731951d6def94f8b4f3bb453e8ec84544b6f1745878e20e53a1f7203 - Sigstore transparency entry: 2666790105
- Sigstore integration time:
-
Permalink:
edoardoscarpaci/varco@79498d3cf3e15d089fc8059a2497b364d1dbe7b6 -
Branch / Tag:
refs/tags/v3.0.0rc1 - Owner: https://github.com/edoardoscarpaci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@79498d3cf3e15d089fc8059a2497b364d1dbe7b6 -
Trigger Event:
push
-
Statement type: