Skip to content

Permission / API restriction library based on Role and list of allowed endpoints / methods

Notifications You must be signed in to change notification settings

DasithKuruppu/PermiRole

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

  1. npm install -save DasithKuruppu/PermiRole

Usage

var UserRoles= [
   {
       permissions: {
           role: 'default',
           allowed: [
               {
                   path: '/',
                   method: ['GET'],
                   fields: ['name', 'age']
               },
               {
                   path:'/users?.+',
                   method:['GET'],
                   fields:[]
               }

           ]
       }
   }
]
var PermiRole=require('permirole')(UserRoles,function(RequestContainer){
/*What to do if route / request is allowed
  RequestContainer={request:request,response:res,next:next,permissions:UserPermissions}
*/
 RequestContainer.next();
},function(err,RequestContainer){
/*What to do if route / request is not allowed */
 RequestContainer.next(new Error(err.message));
});

Run Tests

  1. npm install
  2. npm test

About

Permission / API restriction library based on Role and list of allowed endpoints / methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published