1.0.0 ⢠Published 4 months ago
node-red-contrib-multiauth v1.0.0
node-red-contrib-multiauth
š Secure multi-user authentication for Node-RED with Basic Auth, password hashing, and route-based access control (ACL).
š Features
ā
Basic Authentication (multiple users)
ā
Hashed Passwords (bcrypt
)
ā
Access Control (ACL) based on JSON rules
ā
Wildcard Route Support (e.g., api/myroute/*
)
ā
Optimized for Performance (users loaded once)
š Installation
1ļøā£ Install via npm
cd ~/.node-red
npm install node-red-contrib-multiauth
2ļøā£ Add Middleware to Node-RED
Edit your settings.js file:
const { basicAuthMiddleware, loadUsers } = require("node-red-contrib-multiauth");
// load users once at startup
loadUsers("./users.json");
module.exports = {
// ....
// register auth middleware
httpMiddleware: basicAuthMiddleware
// ...
};
āļø Add User
Create a users.json file:
{
"myuser1": {
"password": "$2b$10$hashedpassword...",
"acl": ["*"]
},
"myuser 2": {
"password": "$2b$10$hashedpassword...",
"acl": ["/api/data/*"]
}
}
š Passwords are stored as bcrypt hashes
node -e "console.log(require('bcrypt').hashSync(process.argv[1], 10));" your-password-here
š¬ Testing
Run Jest tests:
npm test
š” Security
- ā Prevents Timing Attacks (bcrypt.compare())
- ā Protects Against Injection (safe object access)
š License
MIT License - Free to use and modify.
1.0.0
4 months ago