cabrel-hapi-acl
v0.1.3
Published
ACL Plugin for Hapi
Downloads
6
Readme
cabrel-hapi-acl
ACL plugin for Hapi
Options
tagprefix- String; Defaults toaclrequest- String; Defaults toauth.credentials. Can be dot notation or a single stringtags- Array(String); Defaults to['auditors', 'admins']validation- Objectauditors- Objectauditor- Defaults to a boolean value (true)
admins- Objectadmin- 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'
