0.2.0 • Published 3 years ago
mizala-gatekeeper v0.2.0
mizala-gatekeeper
This is an authentication and authorization package that exposes a gatekeeper function to check for authorized access
Features
- Expose a gatekeeper that ensure secure requests to protected resources
- Easy Installation and Use
Installation
npm install mizala-gatekeeper
which would inject the following into the project's package.json
"dependencies": {
"mizala-gatekeeper": "^0.0.1"
}
Initialization
const {gatekeeper} = require("mizala-gatekeeper");
Basic functionality
- Receive an optional list of permission strings(each snake_cased)
- Also recieves an optional matchAll(boolean) argument defaults to false, to inform it whether user must possess all stated permissions or not
router.get("/protected/path", gatekeeper(), ...anyother middlewares, requestHandler);
router.get("/another/protected/path", ...anyother middlewares, gatekeeper(), requestHandler);
router.get("/another/protected/path", ...anyother middlewares, gatekeeper(['generate_reports','fight_me']), requestHandler);
router.get("/a/protected/path", ...anyother middlewares, gatekeeper(['generate_reports','fight_me'], true), requestHandler);
Prerequisites
- Have jest installed on machine
Tests
Cli
npm install
npm test