Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Casbin | 15,768 | 638 | 9 days ago | 240 | July 28, 2023 | 27 | apache-2.0 | Go | ||
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN | ||||||||||
Spicedb | 3,878 | 5 | a day ago | 62 | August 10, 2023 | 121 | apache-2.0 | Go | ||
Open Source, Google Zanzibar-inspired fine-grained permissions database | ||||||||||
Oso | 3,187 | 11 | a month ago | 48 | April 03, 2023 | 112 | apache-2.0 | Rust | ||
Oso is a batteries-included framework for building authorization in your application. | ||||||||||
Node Casbin | 2,321 | 32 | 108 | 15 days ago | 128 | July 29, 2023 | 16 | apache-2.0 | TypeScript | |
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser | ||||||||||
Gin Admin | 2,283 | 1 | 14 days ago | 19 | November 14, 2021 | 55 | mit | Go | ||
A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin + Wire DI. | ||||||||||
Jcasbin | 2,221 | 8 | 8 | 17 days ago | 84 | August 15, 2023 | apache-2.0 | Java | ||
An authorization library that supports access control models like ACL, RBAC, ABAC in Java | ||||||||||
Accesscontrol | 1,676 | 87 | 69 | 2 years ago | 10 | February 24, 2018 | 39 | mit | TypeScript | |
Role and Attribute based Access Control for Node.js | ||||||||||
Pycasbin | 1,172 | 2 | 39 | 4 days ago | 110 | September 16, 2023 | 3 | apache-2.0 | Python | |
An authorization library that supports access control models like ACL, RBAC, ABAC in Python | ||||||||||
Php Casbin | 1,143 | 27 | 27 | a month ago | 60 | August 31, 2023 | 4 | apache-2.0 | PHP | |
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP . | ||||||||||
Casbin.net | 992 | 1 | 9 | 6 days ago | 45 | September 16, 2023 | 28 | apache-2.0 | C# | |
An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#) |
News: still worry about how to write the correct node-casbin
policy? Casbin online editor is coming to help!
node-casbin
is a powerful and efficient open-source access control library for Node.JS projects. It provides support for enforcing authorization based on various access control models.
![]() |
![]() |
![]() |
![]() |
---|---|---|---|
Casbin | jCasbin | node-Casbin | PHP-Casbin |
production-ready | production-ready | production-ready | production-ready |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|
PyCasbin | Casbin.NET | Casbin-CPP | Casbin-RS |
production-ready | production-ready | beta-test | production-ready |
https://casbin.org/docs/overview
# NPM
npm install casbin --save
# Yarn
yarn add casbin
New a node-casbin
enforcer with a model file and a policy file, see Model section for details:
// For Node.js:
const { newEnforcer } = require('casbin');
// For browser:
// import { newEnforcer } from 'casbin';
const enforcer = await newEnforcer('basic_model.conf', 'basic_policy.csv');
Note: you can also initialize an enforcer with policy in DB instead of file, see Persistence section for details.
Add an enforcement hook into your code right before the access happens:
const sub = 'alice'; // the user that wants to access a resource.
const obj = 'data1'; // the resource that is going to be accessed.
const act = 'read'; // the operation that the user performs on the resource.
// Async:
const res = await enforcer.enforce(sub, obj, act);
// Sync:
// const res = enforcer.enforceSync(sub, obj, act);
if (res) {
// permit alice to read data1
} else {
// deny the request, show an error
}
Besides the static policy file, node-casbin
also provides API for permission management at run-time.
For example, You can get all the roles assigned to a user as below:
const roles = await enforcer.getRolesForUser('alice');
See Policy management APIs for more usage.
Casbin provides two sets of APIs to manage permissions:
https://casbin.org/docs/supported-models
https://casbin.org/docs/adapters
https://casbin.org/docs/watchers
https://casbin.org/docs/role-managers
This project exists thanks to all the people who contribute.
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
This project is licensed under the Apache 2.0 license.
If you have any issues or feature requests, please contact us. PR is welcomed.