All Projects → casbin → Node Casbin

casbin / Node Casbin

Licence: apache-2.0
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Node Casbin

Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
Stars: ✭ 10,872 (+518.78%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, casbin, abac, authz
lua-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Lua (OpenResty)
Stars: ✭ 43 (-97.55%)
Mutual labels:  acl, auth, authorization, permission, rbac, access-control, abac, authz, casbin
casbin-ex
An authorization library that supports access control models like ACL, RBAC, ABAC in Elixir
Stars: ✭ 37 (-97.89%)
Mutual labels:  acl, auth, authorization, permission, rbac, access-control, abac, authz, casbin
Casbin.net
An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
Stars: ✭ 535 (-69.55%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, casbin, abac
Pycasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Python
Stars: ✭ 625 (-64.43%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, casbin, abac
dart-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Dart/Flutter
Stars: ✭ 30 (-98.29%)
Mutual labels:  acl, auth, authorization, rbac, access-control, abac, authz, casbin
Casbin Rs
An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
Stars: ✭ 375 (-78.66%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, casbin, abac
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (-97.1%)
Mutual labels:  acl, auth, authorization, rbac, access-control, abac, authz, casbin
Jcasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Java
Stars: ✭ 1,335 (-24.02%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, casbin, abac
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (-98.46%)
Mutual labels:  acl, auth, permission, rbac, access-control, abac, casbin
Gorm Adapter
Gorm adapter for Casbin
Stars: ✭ 373 (-78.77%)
Mutual labels:  authorization, rbac, auth, acl, access-control, casbin, abac
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (-95.96%)
Mutual labels:  acl, authorization, permission, rbac, access-control, abac, authz
Casbin4D
An authorization library that supports access control models like ACL, RBAC, ABAC in Delphi
Stars: ✭ 25 (-98.58%)
Mutual labels:  acl, auth, authorization, rbac, access-control, abac, casbin
Php Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .
Stars: ✭ 865 (-50.77%)
Mutual labels:  authorization, rbac, auth, acl, access-control, permission, abac
Openstack Policy Editor
A Casbin Policy Editor for OpenStack
Stars: ✭ 28 (-98.41%)
Mutual labels:  authorization, rbac, auth, acl, access-control, casbin, abac
Casbin Cpp
An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
Stars: ✭ 113 (-93.57%)
Mutual labels:  authorization, rbac, acl, access-control, permission, casbin, abac
sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Stars: ✭ 53 (-96.98%)
Mutual labels:  acl, auth, permission, access-control, abac, casbin
Casbin Server
Casbin as a Service (CaaS)
Stars: ✭ 171 (-90.27%)
Mutual labels:  authorization, rbac, acl, access-control, casbin, abac
Caddy Authz
Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.
Stars: ✭ 221 (-87.42%)
Mutual labels:  authorization, rbac, acl, access-control, casbin, abac
Chi Authz
chi-authz is an authorization middleware for Chi
Stars: ✭ 248 (-85.89%)
Mutual labels:  authorization, rbac, acl, access-control, casbin, abac

Node-Casbin

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

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/en/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/en/supported-models

Policy persistence

https://casbin.org/docs/en/adapters

Policy consistence between multiple nodes

https://casbin.org/docs/en/watchers

Role manager

https://casbin.org/docs/en/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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].