Skip to main content

Overview

Casbin is a powerful and efficient open-source access control library. It provides support for enforcing authorization based on various access control models.

All the languages supported by Casbin:​

golangjavanodejsphp
CasbinjCasbinnode-CasbinPHP-Casbin
production-readyproduction-readyproduction-readyproduction-ready
pythondotnetc++rust
PyCasbinCasbin.NETCasbin-CPPCasbin-RS
production-readyproduction-readyproduction-readyproduction-ready

Feature set for different languages​

FeatureGoJavaNode.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βœ…βœ…βœ…βœ…βœ…βŒβœ…βŒβŒβŒβœ…βœ…

We are always working our best to make Casbin have the same set of features for all languages. But the reality is not that beautiful. The current progress is as the above table. βœ… for Watcher or Role Manager only means having the interface in the core library. Whether there is an available watcher or role manager implementation is another question.

What is Casbin?​

What Casbin does:

  1. enforce the policy in the classic {subject, object, action} form or a customized form as you defined, both allow and deny authorizations are supported.
  2. handle the storage of the access control model and its policy.
  3. manage the role-user mappings and role-role mappings (aka role hierarchy in RBAC).
  4. support built-in superuser like root or administrator. A superuser can do anything without explicit permissions.
  5. multiple built-in operators to support the rule matching. For example, keyMatch can map a resource key /foo/bar to the pattern /foo*.

What Casbin does NOT do:

  1. authentication (aka verify username and password when a user logs in)
  2. manage the list of users or roles. I believe it's more convenient for the project itself to manage these entities. Users usually have their passwords, and Casbin is not designed as a password container. However, Casbin stores the user-role mapping for the RBAC scenario.