Node Casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser
Alternatives To Node Casbin
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Casbin15,7686389 days ago240July 28, 202327apache-2.0Go
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN
Spicedb3,8785a day ago62August 10, 2023121apache-2.0Go
Open Source, Google Zanzibar-inspired fine-grained permissions database
Oso3,18711a month ago48April 03, 2023112apache-2.0Rust
Oso is a batteries-included framework for building authorization in your application.
Node Casbin2,3213210815 days ago128July 29, 202316apache-2.0TypeScript
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser
Gin Admin2,283114 days ago19November 14, 202155mitGo
A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin + Wire DI.
Jcasbin2,2218817 days ago84August 15, 2023apache-2.0Java
An authorization library that supports access control models like ACL, RBAC, ABAC in Java
Accesscontrol1,67687692 years ago10February 24, 201839mitTypeScript
Role and Attribute based Access Control for Node.js
Pycasbin1,1722394 days ago110September 16, 20233apache-2.0Python
An authorization library that supports access control models like ACL, RBAC, ABAC in Python
Php Casbin1,1432727a month ago60August 31, 20234apache-2.0PHP
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .
Casbin.net992196 days ago45September 16, 202328apache-2.0C#
An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
Alternatives To Node Casbin
Select To Compare


Alternative Project Comparisons
Readme

Node-Casbin

NPM version NPM download install size codebeat badge GitHub Actions Coverage Status Release Discord

💖 Looking for an open-source identity and access management solution like Okta, Auth0, Keycloak ? Learn more about: Casdoor

casdoor

News: still worry about how to write the correct node-casbin policy? Casbin online editor is coming to help!

casbin Logo

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.

All the languages supported by Casbin:

golang java nodejs php
Casbin jCasbin node-Casbin PHP-Casbin
production-ready production-ready production-ready production-ready
python dotnet c++ rust
PyCasbin Casbin.NET Casbin-CPP Casbin-RS
production-ready production-ready beta-test production-ready

Documentation

https://casbin.org/docs/overview

Installation

# NPM
npm install casbin --save

# Yarn
yarn add casbin

Get started

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.

Policy management

Casbin provides two sets of APIs to manage permissions:

  • Management API: the primitive API that provides full support for Casbin policy management.
  • RBAC API: a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code.

Official Model

https://casbin.org/docs/supported-models

Policy persistence

https://casbin.org/docs/adapters

Policy consistence between multiple nodes

https://casbin.org/docs/watchers

Role manager

https://casbin.org/docs/role-managers

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

This project is licensed under the Apache 2.0 license.

Contact

If you have any issues or feature requests, please contact us. PR is welcomed.

Popular Abac Projects
Popular Rbac Projects
Popular Security Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Javascript
Typescript
Authentication
Permission
Authorization
Acl
Rbac
Access Control
Casbin
Abac