Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 964 Bytes

README.md

File metadata and controls

50 lines (38 loc) · 964 Bytes

Security Route

This microu module should be used if you need a micro access blocking to your routes. To use this service you will need to have some code to:

  • Use express in your project
  • Create your session validation service
  • Setup your project roles
  • Create a simple way to retreive your users

Basic usage

var Router = require('security-route').Router;

module.exports = function(){

    /* 
    * app -> Express App
    * roleList -> array
    * sessionValidationService -> object
    */

    Router = Router(app, roleList, sessionValidationService);

    Router.addRoute({
        verb: 'get',
        path: '/login',
        action: Controller.controllerAction,
        role: ['ROLE_ADMIN', 'ROLE_USER']
    });

//...

}

Role List example

module.exports = {
  default_role: "ANONYMOUS",
  roles: [
    'ANONYMOUS',
    'ROLE_USER',
    'ROLE_HR',
    'ROLE_CONSULTANT',
    'ROLE_ADMIN'
  ]
}