Registry / auth-security / acl
library0.2jsnpmunverified

ACL (Access Control List) library for Node.js, version 0.4.11, last updated in 2019. Provides role-based permission management with support for Redis, MongoDB, and in-memory backends. Includes Express middleware for protecting routes. Compared to alternatives like accesscontrol or casl, acl is older and more minimalistic, with a callback/promise API and limited TypeScript support. The package is in maintenance mode; no active development.

npm install acl
INSTALL
IMPORT
SIG · ACL
A
acl
auth-securityjavascriptv0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

acl
const acl = require('acl')
import acl from 'acl'
Package is CommonJS only; no default ESM export.
new acl()
const acl = new acl(new acl.redisBackend(redisClient))
const acl = new acl.redisBackend()
acl must be instantiated with a backend instance.
acl.middleware
app.use(acl.middleware())
app.use(acl.middleware)
middleware() returns a function; must be called with () even without options.

Creates an ACL instance with Redis backend, allows admin full access to blogs, assigns user 'john' as admin, and checks if john can delete blogs.

const acl = require('acl'); const redis = require('redis'); const client = redis.createClient(); const aclInstance = new acl(new acl.redisBackend(client)); aclInstance.allow('admin', 'blogs', '*'); aclInstance.addUserRoles('john', 'admin'); aclInstance.isAllowed('john', 'blogs', 'delete', (err, allowed) => { console.log('Allowed:', allowed); // true });
Debug
Known issues
gotchaacl.allow() with wildcard '*' does not grant permissions on resources that are not explicitly listed.
fix
Use acl.allow('admin', '*', '*') to grant all permissions on all resources, or list all resources explicitly.
affects: >=0.0.0
gotchaThe library does not chain methods; each call returns a promise (or calls callback).
fix
Use promises or callbacks; do not attempt method chaining.
affects: >=0.0.0
deprecatedCallbacks are deprecated; use promises instead.
fix
Omit callback parameter and use .then().catch() or async/await.
affects: >=0.4.0
gotchaRedis backend requires a connected client; passing an unconnected client will cause errors.
fix
Ensure redisClient is connected before instantiating ACL.
affects: >=0.0.0
gotchamiddleware() with no parameters restricts all routes; you must specify resource and permissions options.
fix
Pass option object with 'role' and 'resource' or use acl.middleware(3, 'user', 'username') for dynamic roles.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: acl.allow is not a function
The variable acl shadows the module import. You used 'new acl()' and then tried to call acl.allow(). After instantiating, the 'acl' variable refers to the instance, not the module.
fix
Use a different variable name for the instance, e.g., const aclInstance = new acl(new acl.redisBackend(client)); aclInstance.allow(...).
Error: Redis connection to 127.0.0.1:6379 failed
Redis server is not running or not accessible.
fix
Start Redis server with 'redis-server' or provide correct host/port in redis.createClient().
Cannot find module 'acl'
Package not installed.
fix
Run 'npm install acl' in your project directory.
acl.middleware is not a function
Attempted to use acl.middleware directly as a middleware instead of calling it.
fix
Use app.use(acl.middleware()) instead of app.use(acl.middleware).
Upgrade
Version history
0.2latest on npm
Audit
Dependencies
redisoptionalRequired if using Redis backend
mongodboptionalRequired if using MongoDB backend
Agent activity
58 hits · last 30 days
node
46
Resources