security-route
v1.3.2
Published
Micro module to protect routes based in a specific access role
Downloads
4
Readme
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'
]
}