phellipeandrade / Rbac
Licence: mit
Hierarchical Role-Based Access Control for Node.js
Stars: ✭ 254
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Rbac
Accesscontrol
Role and Attribute based Access Control for Node.js
Stars: ✭ 1,723 (+578.35%)
Mutual labels: authorization, rbac, permissions, acl
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (-38.98%)
Mutual labels: authorization, rbac, permissions, acl
Rbac
Hierarchical Role Based Access Control for NodeJS
Stars: ✭ 857 (+237.4%)
Mutual labels: authorization, rbac, permissions, role
rbac-tool
Rapid7 | insightCloudSec | Kubernetes RBAC Power Toys - Visualize, Analyze, Generate & Query
Stars: ✭ 546 (+114.96%)
Mutual labels: permissions, acl, authorization, rbac
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (-72.05%)
Mutual labels: acl, authorization, rbac, role
Casbin4D
An authorization library that supports access control models like ACL, RBAC, ABAC in Delphi
Stars: ✭ 25 (-90.16%)
Mutual labels: permissions, acl, authorization, rbac
Laratrust
Handle roles and permissions in your Laravel application
Stars: ✭ 1,799 (+608.27%)
Mutual labels: authorization, rbac, permissions, acl
Negroni Authz
negroni-authz is an authorization middleware for Negroni
Stars: ✭ 152 (-40.16%)
Mutual labels: authorization, rbac, acl
Vakt
Attribute-based access control (ABAC) SDK for Python
Stars: ✭ 92 (-63.78%)
Mutual labels: authorization, permissions, acl
Casbin Server
Casbin as a Service (CaaS)
Stars: ✭ 171 (-32.68%)
Mutual labels: authorization, rbac, acl
Casbin Cpp
An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
Stars: ✭ 113 (-55.51%)
Mutual labels: authorization, rbac, acl
Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
Stars: ✭ 10,872 (+4180.31%)
Mutual labels: authorization, rbac, acl
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (-68.9%)
Mutual labels: authorization, permissions, acl
Php Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .
Stars: ✭ 865 (+240.55%)
Mutual labels: authorization, rbac, acl
Jcasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Java
Stars: ✭ 1,335 (+425.59%)
Mutual labels: authorization, rbac, acl
Laravel Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Stars: ✭ 136 (-46.46%)
Mutual labels: authorization, permissions, acl
Openstack Policy Editor
A Casbin Policy Editor for OpenStack
Stars: ✭ 28 (-88.98%)
Mutual labels: authorization, rbac, acl
Rbac.dev
A collection of good practices and tools for Kubernetes RBAC
Stars: ✭ 115 (-54.72%)
Mutual labels: authorization, rbac, permissions
Caddy Authz
Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.
Stars: ✭ 221 (-12.99%)
Mutual labels: authorization, rbac, acl
Hierarchical Role-Based Access Control for Node.js
- ⏱ Lightweight
- 🔥 Blazing Fast
- ⚡️️ Zero dependency
Features
- Focused on operations
- Scalable
- Each role is given specific access rights for every operation
- High granularity in assigning rights
Thanks
This project scaffold was built with a modified version of webpack-library-starter
Thanks to Karl Düüna (DeadAlready) and his awesome post on medium
Getting Started
Install
yarn add @rbac/rbac
or npm install @rbac/rbac
RBAC is a curried function thats initially takes an object with configurations, then returns another function that takes an object with roles, finally returns an object that holds "can" property that is a function.
You can use it in many ways, below is one of them:
Setup RBAC config
Property | Type | Params | Default | Description |
---|---|---|---|---|
logger | Function | role: String operation: String result: Boolean |
defaultLogger | Function that logs operations to console |
enableLogger | Boolean | true | Enable or disable logger |
Creating some roles
RBAC expects an object with roles as property names.
Property | Type | Example | Description |
---|---|---|---|
can | Array | ['products:*'] |
Array of strings, list of operations that user can do, since 1.1.0 also support glob |
when | Function or Promise | (params , done ) => done (null , true ) |
Optional Promise that should resolve in Truthy or Falsy or Callback function that receives params and done as properties, should return done passing errors, and result |
inherits | Array | ['user'] |
Optional Array of strings, list of roles inherited by this role |
Truthy or Falsy values. Example:
IMPORTANT! "when" property should be either a Callback function that receives params and done or a Promise that should resolve inconst roles = {
supervisor: {
can: [{ name: 'products:find', when: (params, done) => {
// done receives error as first argument and Truthy or Falsy value as second argument
done(error, false);
}}]
},
admin: {
can: [{name: 'products:*', when: new Promise((resolve) => {
resolve(true);
})}]
}
};
Check if user can do some operation
Param | Type | Example | Description |
---|---|---|---|
First | String | 'admin' |
Array of strings, list of operations that user can do |
Second | String, Glob (Wildcard), Regex | 'products:find' |
Operation to validate |
Third | Any | {registered: true} |
Optional Params that will flow to "when" callback Function |
Want more? Check out the examples folder.
Roadmap
- [X] Wildcard support
- [X] Regex support
- [ ] Update roles in runtime
Contributing
Contributions are welcome!
- Build RBAC
- Run
yarn install
to get RBAC's dependencies - Run
yarn build
to produce minified version of RBAC.
- Development mode
- Having all the dependencies installed run
yarn dev
. This command will generate a non-minified version of your library and will run a watcher so you get the compilation on file change.
- Running the tests
- Run
yarn test
- Scripts
-
yarn build
- produces production version of your library under thelib
folder -
yarn dev
- produces development version of your library and runs a watcher -
yarn test
- well ... it runs the tests :) -
yarn test:watch
- same as above but in a watch mode
License
This project is under MIT License [https://opensource.org/licenses/MIT]
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].