1.0.4 • Published 8 years ago

matrix-authorization v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Matrix authorization

Node based permission checks in Node.

Build Status Coverage Status

API

/*
 * Create some permissions to check against.
 */

var permissions = {
  user: ['create', 'read', 'update', 'delete'],
  post: ['create', 'read', 'update', 'delete'],
  tag: [{list: [{limit: [10, 20, 30, 40, 50]}]}]
}

/*
 * Instantiate the module, passing in your permissions object.
 */
var matrix = require('matrix-auth')(permissions)

/*
 * Create a function to call with the values you want to check.
 * Pass in an array of the required nodes.
 */

var checkFn1 = matrix.createCheck(['user.create', 'tag.list.limit.50'])

/*
 * Call the created function with the values you want to check.
 */

// matches everything downstream of the *
checkFn1({user: ['*'], tag: [{list: ['*']}]}) // true

// matches everything downstream of the *
checkFn1({user: ['*'], tag: ['*']}) // true

//missing tag node.
checkFn1({user: ['*']}) // false

Todo

  • More robust argument handling. Accept comma delimited strings, in addition to arrays.
  • Accept an array of pure node values into the function returned by createCheck
  • fuzzy matching where possible, ie node.50 matches node.0-50
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.1

8 years ago