access-policy
Advanced tools
Encodes and decodes policy JSON files for use with web applications.
Weekly downloads
Readme
{
"statements": [ //Array
{
"effect": "deny", // String
"action": "*", // String or Array
"resource": [ // String or Array
"/user/${user.id}/*"
],
"condition": { // Object
"equals": { // Object
"key": "value"
}
},
"restiction": {
"equals": { // Object
"key": "value"
}
}
}
]
}
deny
.GET
, POST
, PUT
, DELETE
)Encoding a statement happens at run time (if the provided statement hasn't already been encoded) and evaluated against data provided.
When encoding a policy variables are provided via template literal style strings.
{
"key": "${value}"
}
The following object is what the parser expects to recieve.
{
Action: 'GET',
Resource: 'user/12345',
property: 'value',
property2: {
key: 'value',
key2: 'value'
}
}
The following properties are required for validation:
GET
, POST
, PUT
, DELETE
)pathname
of the requesting URLBeyond the required properties you can inlude arbitrary properties that can be nested and accessed during encoding.
// Template
{
"statements": [
{
"effect": "deny",
"action": "*",
"resource": [
"/user/${user.id}/*"
],
"restiction": {
"equals": {
"account_id": "${accountId}"
}
}
}
]
}
// Data
{
Action: "GET",
Resource: "/user/1234",
accountId: "5678"
}