cabrel-hapi-acl

0.1.3 • Public • Published

cabrel-hapi-acl

ACL plugin for Hapi

Options

  • tagprefix - String; Defaults to acl
  • request - String; Defaults to auth.credentials. Can be dot notation or a single string
  • tags - Array(String); Defaults to ['auditors', 'admins']
  • validation - Object
    • auditors - Object
      • auditor - Defaults to a boolean value (true)
    • admins - Object
      • admin - Defaults to a boolean value (true)

Example

This example expects the request to resolve request.auth.credentials to an object with the following:

{
    auditorFor: ['TEST1', 'TEST2'],
    adminFor: ['TEST3', 'TEST4']
}

The cooresponding plugin configuration:

{
  tagprefix: 'acl',
  request: 'auth.credentials',
  tags: ['auditors', 'admins'],
  validation: {
    'auditors': {
       'auditorFor':  ['TEST1', 'TEST2']
    },
    'admins': {
       'adminFor': ['TEST3', 'TEST4']
    }
  }
}

The plugin builds strings in the form of tagprefix + tags[n] and then searches request.route.tags for matching entries. If a match is found, a validation test happens where the request.auth.credentials is checked for auditorFor to contain either 'TEST1' or 'TEST2'

Readme

Keywords

none

Package Sidebar

Install

npm i cabrel-hapi-acl

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • cabrel