
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rbac-express
Advanced tools
JWT for authentication and role-based access control, which makes it adaptable to many Node.js web frameworks.
A simple and lightweight middleware for implementing Role-Based Access Control (RBAC) in Express.js applications using JWT.
Install the library using npm:
npm install rbac-express
on your main app should install Express.JS & and jsonwebtoken for create jwt.
const express = require("express");
const jwt = require("jsonwebtoken");
const { authorize } = require("rbac-express");
const app = express();
// JWT secret key
const SECRET_KEY = "your-secret-key";
//Simulate user login and generate JWT
app.post("/login", (req, res) => {
const user = { id: 1, username: "user1", roles: ["admin"] }; // Replace with your user data
const token = jwt.sign(user, SECRET_KEY, { expiresIn: "1h" });
res.json({ token });
});
// Protected route
app.get(
"/admin",
authorize({
secret: SECRET_KEY, // Your JWT secret key
roles: ["admin"], // Roles allowed to access this route
}),
(req, res) => {
res.send("Welcome, Admin!");
}
);
// Start the server
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});
The JWT payload must contain a roles field, which is an array of roles assigned to the user. And you can add any other fields to the token as you wish.
{
"id": 1,
"username": "user1",
"roles": ["admin", "editor"]
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
H. Kavinda Dissanayake
Email : kavindapvt@gmail.com
Linkdin : www.linkedin.com/in/dissanayake-kavinda
GitHub : https://github.com/kavinda-KPD
FAQs
JWT for authentication and role-based access control, which makes it adaptable to many Node.js web frameworks.
We found that rbac-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.