Apache Shiro permission style using Trie data structure
npm install shiro-permsCreate, check and manipulate permissions using a Trie data object and Apache Shiro write style.
Module exposes a class that can be used to create permissions objects. Each instance object represents a set of credentials which can be manipulated and verified using instance methods.
``js`
const ShiroPerms = require('shiro-perms');
`js`
import ShiroPerms from 'shiro-perms';$3
* https://rjblopes.github.io/shiro-perms
Use:
``
npm i shiro-perms
Or
``
yarn add shiro-perms
Use:
``
npm run test
Or
``
yarn testUsage
$3
Using class constructor:
`js`
const perms = new ShiroPerms();
Static methods:
`js`
const perms = ShiroPerms.from('store:view,edit store:*:1123');`js`
const perms = ShiroPerms.from(['store:view,edit', 'store:*:1123']);$3
Check ALL permissions - AND
`js
perms.check('store:view:9999')
// True
perms.check('store:view store:edit:*')
// True
perms.check(['store:view', 'store:edit:9999'])
// False
`
Check ANY permissions - OR
`js``
perms.checkAny(['store:view', 'store:edit:9999'])
// True
* msgpack5 - A msgpack v5 implementation for node.js
Ricardo Lopes - Initial work* - rjblopes
This project is licensed under the MIT License
* Inspired by: https://github.com/entrecode/shiro-trie