pycasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Python
Decision gist · record as of 2026-08-14
Yes. PyCasbin is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It is well-suited for projects needing flexible, model-driven access control. Install it if your application requires authorization beyond simple role checks or if you anticipate changing authorization rules frequently.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a model configuration file (model.conf) and policy file (policy.csv) to define access control rules; the library does not generate these automatically.
- Low install friction with only 2 runtime dependencies (simpleeval and wcmatch).
- Active maintenance with a recent release on 2026-02-02 and last commit on 2026-08-13; repository shows 1759 stars and is not archived.
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions beyond attribution and liability disclaimers.
last release 2026-02-02 (193 days) · last repo commit 2026-08-13 · 1,759 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,075,516 downloads/mo, #3,315 on PyPI
Alternatives
Verify before relying
pip install pycasbin
from pycasbin import Enforcer
enforcer = Enforcer('model.conf', 'policy.csv')
if enforcer.enforce('alice', 'data1', 'read'):
print('Access allowed')- Whether async support (mentioned as available since 1.23.0) is fully stable and production-ready in version 2.8.0.
- Performance characteristics and scalability limits for large policy sets or high-throughput authorization checks.
- Integration patterns and best practices for frameworks beyond the mentioned Django Authorization library.
What it is and what it does
PyCasbin is an access control library that evaluates authorization decisions by matching requests against configurable policies. It abstracts access control into a CONF file following the PERM metamodel (Policy, Effect, Request, Matchers), allowing you to define and enforce rules without changing code. The library supports multiple models—ACL (basic subject-object-action rules), RBAC (role hierarchies and domain/tenant separation), ABAC (attribute-based matching), and RESTful patterns—making it adaptable to different authorization schemes.
You provide a model configuration that defines how requests are matched against policies, then load or manage policies at runtime. PyCasbin handles the matching logic, role management, and policy persistence, but does not authenticate users or manage the user/role registry itself—those remain your application's responsibility. It supports both synchronous and asynchronous enforcement, built-in operators for pattern matching, and deny-override semantics where explicit denials take precedence.
Use it for
- Enforce role-based permissions in a web application where users have different roles with different capabilities per resource.
- Implement multi-tenant authorization where the same user has different roles and permissions in different domains or tenants.
- Build RESTful API access control matching HTTP methods and resource paths to user roles and permissions.
- Manage hierarchical role structures where roles inherit permissions from parent roles, reducing policy duplication.
- Enforce attribute-based rules where access depends on resource properties or request context.
- Centralize authorization logic separate from business code so policies can be updated without redeployment.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
PyCasbin is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively. It is well-suited for projects needing flexible, model-driven access control. Install it if your application requires authorization beyond simple role checks or if you anticipate changing authorization rules frequently.
Install
pycasbin on PyPI
Before you install
Low install friction with only 2 runtime dependencies (simpleeval and wcmatch). Active maintenance with a recent release on 2026-02-02 and last commit on 2026-08-13; repository shows 1759 stars and is not archived.
Requires a model configuration file (model.conf) and policy file (policy.csv) to define access control rules; the library does not generate these automatically.
License in practice
Licensed under Apache 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install pycasbin
from pycasbin import Enforcer
enforcer = Enforcer('model.conf', 'policy.csv')
if enforcer.enforce('alice', 'data1', 'read'):
print('Access allowed')
Verify before relying
- Whether async support (mentioned as available since 1.23.0) is fully stable and production-ready in version 2.8.0.
- Performance characteristics and scalability limits for large policy sets or high-throughput authorization checks.
- Integration patterns and best practices for frameworks beyond the mentioned Django Authorization library.
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagessimpleevalwcmatch |
| Maintenance | Actively maintained 193 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,075,516 / month, #3,315 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: pycasbin-2.8.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “RBAC ABAC ACL”
- pycasbinPyCasbin enforces access control policies using models like ACL,…
- casbin-async-sqlalchemy-adapterProvides an asynchronous SQLAlchemy adapter for PyCasbin, enabling…
- casbinCasbin enforces access control policies (ACL, RBAC, ABAC) by…
Give your agent the search over MCP, or paste the wish link into any chat.
More Security packages
Provides Python bindings to the FreeDesktop.org Secret Service API for securely storing and retrieving passwords and secrets through GNOME Keyring, KWallet, or KeePassXC.
MSAL for Python handles OAuth2 and OpenID Connect authentication with Microsoft identity services, managing token acquisition, caching, and refresh for applications integrating with Microsoft Entra ID, Microsoft Accounts, and Azure AD B2C.
joserfc implements JOSE standards (JWS, JWE, JWK, JWT, and related RFCs) for signing, encrypting, and managing JSON-based cryptographic tokens in Python.
Authlib provides a complete implementation of OAuth 1.0, OAuth 2.0, and OpenID Connect 1.0 for building both authentication clients and servers, with built-in support for JWS, JWK, JWA, and JWT standards.
Provides low-level CFFI bindings to the official Argon2 password hashing algorithm for use by libraries and applications that need direct access to Argon2 without higher-level abstractions.
ADAL for Python authenticates applications with Azure Active Directory to obtain tokens for accessing Azure AD-protected resources.
Install only if maintaining existing code that already depends on it, and plan a migration.
See also casbin · casbin-sqlalchemy-adapter · casbin-async-sqlalchemy-adapter · sqlalchemy-adapter · django-prbac · auth · zope.security · oslo.policy · dry-rest-permissions · invenio-records-permissions