
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@vonage/acl-express
Advanced tools
A stateless access control middleware for Express servers
Install using npm
:
$ npm install @vonage/acl-express
then in your project require the package:
const acl = require('@vonage/acl-express');
lastly, you must configure the module for it to work:
acl.config({...});
You must supply a configuration object to the module for it to work.
You can use the following configurations:
Property | Required | Type | Description |
---|---|---|---|
path | true | string | This is the path for your rules file |
roleObjectKey | false | string | The name of the user object on the express request object which holds the role field Default Value: user |
defaultRole | false | string | This is the role that will be given to users which do not have a role set for them. |
Example:
acl.config({
path: 'path/to/rule/list',
roleObjectKey: 'myUser',
defaultRole: 'guest'
});
You have to supply a rule file to the module which is built in the following way:
Basic Example:
{
"guest": [
{
"route": "/public",
"methods": [
"GET"
],
"action": "allow"
},
{
"route": "/private",
"methods": "*",
"action": "deny"
}
],
"admin": [
{
"route": "*",
"methods": "*",
"action": "allow"
}
]
}
As seen in the example above, every rule will hold the following fields:
Field | Type | Description |
---|---|---|
route | string | The path for the rule to be applied on |
methods | string or array | An array of HTTP methods to apply this rule on, or * for all methods |
action | string | The action to apply for all requests this rule applies for. Values must be allow or deny |
You can use the Express styled url parameters in your path, i.e.: /path/with/:param
Every rule can have another field which is called subroutes
. this is another array of rules which will allow you a more granular control over which routes to allow and deny access to according to your logic.
Example:
{
"guest": [
{
"path": "/api",
"method": "*",
"action": "allow",
"subroutes": [
{
"path": "/public", // Translates to /api/public
"method": ["GET"],
"action": "allow"
},
{
"path": "/private", // Translates to /api/private
"method": "*",
"action": "deny"
}
]
}
]
}
See the LICENSE file for license rights and limitations (Apache License, Version 2.0)
FAQs
An access control middleware for Express
The npm package @vonage/acl-express receives a total of 0 weekly downloads. As such, @vonage/acl-express popularity was classified as not popular.
We found that @vonage/acl-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.