Skip to content

oandre/security-route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

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'
  ]
}

About

Micro module to protect routes based in a specific access role

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published