1.0.0-hotfix • Published 3 years ago

@fizz.js/node-acl-v2 v1.0.0-hotfix

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

@fizz.js/node-acl-v2

This is an acl (v2) library for express.

install

add dependencies into package.json and run yarn install

configure

please put acl config into config/${env}.json

{
  "acl": {
    "prefix": "acl_",
    "useSingle": true,
    "v2": {
      "baseUrl": "",
      "filename": "acl.json",
      "path": "config",
      "defaultRole": "player",
      "decodedObjectName": "user",
      "roleSearchPath": "user.roles.name",
      "rules": [
        {
          "group": "user",
          "permissions": [
            {
              "resource": "test/*",
              "methods": ["POST", "GET", "PUT"],
              "action": "allow"
            }
          ]
        },
        {
          "group": "player",
          "permissions": [
            {
              "resource": "error/*",
              "methods": ["POST", "GET", "PUT"],
              "action": "allow"
            }
          ]
        }
      ]
    }
  }
}

and you can also configure rules into ${path}/${filename} (e.g. path/acl.json) if you specified path and filename into config.

[
  {
    "group": "user",
    "permissions": [
      {
        "resource": "test/*",
        "methods": ["POST", "GET", "PUT"],
        "action": "allow"
      }
    ]
  },
  {
    "group": "admin",
    "permissions": [
      {
        "resource": "*/*",
        "methods": ["POST", "GET", "PUT"],
        "action": "allow"
      }
    ]
  }
]

test

yarn test

coverage

yarn cover

build

yarn build

docs

yarn docs