1.0.0 • Published 4 years ago

@miluxas/mongoose_rbac v1.0.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

Mongoose Base RBAC

Mongoose_rbac is Role Base Access Control that based on mongoose data base.

Mongoose_rbac does not require any additional changes to your method of development.

NPM version

Installation

By using npm (the recommended way):

npm i @miluxas/mongoose_rbac

Usage

Create an object of model:

const mongooseRbac = new (require('mongoose_rbac'))();

Create some role with:

    mongooseRbac.AddNewRole('Role Title','Description of role')

Create some action with:

    mongooseRbac.AddNewAction('Action Title','Action type','Action url')

If enter for type of action then all type are accepted. If enter a in end of url then only before of * is checked.

Add sub role to a parent role with:

    mongooseRbac.AddSubRole('Parent role Id','Sub role Id')

A role has all sub role permissions.

Add permission of an action to a role with:

    mongooseRbac.AddPermission('Role Id','Action Id')

And finally before each action we can check the access of user's role to it.

    mongooseRbac.CheckAccess('Title of role','action url','Type of action')
        .then(hasAccess=>{
            // if role of user has access to this action return true, else return false
            console.log(hasAccess)
        }); 

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Sponsor this project today ❤️

License

MIT http://rem.mit-license.org

1.0.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago