Bỏ qua đến nội dung chính

Overview

Casbin is an efficient, open-source access control library that enforces authorization and supports multiple access control models.

Implementing rule-based access control is straightforward: define subjects, objects, and permitted actions in a policy file in any format that fits your needs. This pattern is consistent across all Casbin implementations. The model file gives developers and administrators full control over authorization logic—layout, execution flow, and conditions. The Enforcer component evaluates incoming requests against your model and policy.

Các Ngôn Ngữ Được Hỗ Trợ Bởi Casbin

Casbin provides native support for multiple programming languages so you can integrate it into a wide range of projects and workflows:

golangjavanodejsphp
CasbinjCasbinnode-CasbinPHP-Casbin
Sẵn sàng cho sản xuấtSẵn sàng cho sản xuấtSẵn sàng cho sản xuấtSẵn sàng cho sản xuất
pythondotnetc++rust
PyCasbinCasbin.NETCasbin-CPPCasbin-RS
Sẵn sàng cho sản xuấtSẵn sàng cho sản xuấtSẵn sàng cho sản xuấtSẵn sàng cho sản xuất

Feature Set by Language

We aim for feature parity across all language implementations; complete uniformity is not yet achieved.

Tính năngGoJavaNode.jsPHPPythonC#DelphiRustC++LuaDartElixir
Enforcement
RBAC
ABAC
Scaling ABAC (eval())
Adapter
Management API
RBAC API
Batch API
Filtered Adapter
Watcher
Role Manager
Multi-Threading
'in' of matcher
ghi chú

A checkmark (✅) for Watcher or Role Manager means the interface exists in the core library; it does not guarantee that an implementation is available for that language.

Casbin là gì?

Casbin is an authorization library for applications that need controlled access to resources. Typically, a subject (user or service) requests access to an object (resource or entity) to perform an action (e.g. read, write, or delete). You define these actions to match your application. This is the standard { subject, object, action } flow that Casbin handles most often.

Casbin also supports more complex scenarios through roles (RBAC), attributes (ABAC), and other patterns.

Những gì Casbin Làm

  1. Enforces policy in the classic { subject, object, action } format or any custom format you define, including both allow and deny.
  2. Manages storage for the access control model and policies.
  3. Handles user–role and role–role relationships (RBAC role hierarchy).
  4. Supports built-in superusers (e.g. root, administrator) with unrestricted access without explicit rules.
  5. Provides built-in operators for pattern matching (e.g. keyMatch matches /foo/bar against /foo*).

What Casbin Does Not Do

  1. User authentication — validating usernames and passwords at login.
  2. User or role list management — maintaining the list of users or roles.

Most applications already manage users, roles, and credentials. Casbin focuses only on authorization and does not store or verify passwords. In RBAC mode, it does maintain user–role associations.