Skip to content

scull7/privilege-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

privilege-express

An ExpressJS interface for the privilege module.

Example Usage

var app    = require('express')()
var privilege = require('privilege')({
  pathMap: {
    '/my/test/path': 'my:test:path:list'
    '/my/test/path/:id': 'my:test:path:item'
    '/my/other/:id': 'my:other:item'
    '/my/other': 'my:other:list'
    '/my/other/:id/action': 'my:other:item:action'
  },
  roleMap: {
    'root': {
      '*': [ 'get', 'post', 'put', 'delete' ] // root can access all
    },
    'reader': {
      'my:test:path:list': [ 'get' ]
      'my:test:path:item': [ 'get' ]
      'my:other:item': [ 'get' ]
      'my:other:list': [ 'get' ]
    }
    'writer': {
      'my:test:path:list': [ 'get' ]
      'my:test:path:item': [ 'get', 'post', 'put', 'delete' ]
      'my:other:item': [ 'get', 'post', 'put', 'delete' ]
      'my:other:item:action': [ 'post' ]
      'my:other:list': [ 'get' ]
    }
  }
});

app.use(privilege);

About

An ExpressJS interface for the privilege module.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages