-
Quick summary Using this library we can apply policy enforcement point (PEP) in an application. A policy enforcement point (PEP) is responsible for receiving authorization requests that are sent to the policy decision point (PDP) for evaluation. A PEP can be anywhere in an application where data and resources must be protected, or where authorization logic is applied.
-
Version : 1.0.5
npm install modern-pep
const { Authorizer } = require("modern-pep");
const authz = new Authorizer(atomsList, heimdallBaseUrl);
Note:
- atomsList will be array of object. For example:-
[
{
"id": "create-user-ui",
"description": "create a user in the operation ui",
"predicate": "create",
"tags": [
"dataos:type:user"
]
}
]
- heimdallBaseUrl will get from .env file and pass as argument.
If you want to authorize multiple atoms id then use authorizeBatch methode. For this we need to pass two params one is array of atomsId and token of user.
authz.authorizeBatch(atomsId, token);
To perform CRUD opration on yaml file, some methods also available.
const {
createYamlFile,
getAtoms,
addAtom,
updateAtom,
removeAtom,
} = require("modern-pep");
We can also perform CRUD operation from command line.
// To create pep-spec.yaml file
node -e 'require("modern-pep").createYamlFile()'
// To get all the list of atoms from file
node -e 'require("modern-pep").getAtoms()'
// To add new atom
node -e 'require("modern-pep").addAtom({
"id": "operations-app-create-user-ui-test",
"description": "create a user in the operation ui",
"predicate": "create",
"tags": [
"dataos:type:user"
]
})'
// To update existing atom
node -e 'require("modern-pep").updateAtom({
"id": "operations-app-create-user-ui-test",
"description": "test create a user in the operation ui",
"predicate": "create",
"tags": [
"dataos:type:user"
]
})'
// To remove atom from the file
node -e 'require("modern-pep").removeAtom('operations-app-create-user-ui-test')'