
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
hubot-auth-middleware-ext
Advanced tools
Use roles, rooms, and envs to restrict command access in other scripts
Hubot-auth-middleware adds listener middleware for restricting command access. Rooms, roles (hubot-auth), and environments are supported as command restriction concepts.
The core implementation uses listener options attributes that are processed in the auth-middleware's listenerMiddlware. You can create access-controled commands using formats like:
listenerOptions = {"id":"makeSandwich","auth":"true","roles":"sudoers"}
robot.hear /make me a sandwich/, listenerOptions, (msg) ->
msg.send "you are a sandwich"
If the request comes from a user who does not have the sudoers
role, an error notification is logged and replied.
The various access control types can be combined as necessary. The roles
and rooms
values can be strings or arrays, so these all work:
listenerOptionsX = {"id":"secretStuff","auth":"true","roles":["sudoers","admin","wheel"],"rooms":"#situation"}
...
listenerOptionsY = {"id":"reallySecretStuff","auth":"true","roles":"chiefs","rooms":["#panic","#emergency"]}
...
listenerOptionsZ = {"id":"justForClarity","auth":"true","roles":["admin"],"rooms":"#panic"}
Add the hubot-auth-middleware package to hubot/package.json dependencies and hubot/external-scripts.json. hubot-auth-middleware requires the hubot-auth script to function properly.
Hubot-auth-middleware supports environment variables:
You will need a recent Hubot version (supporting middleware). If middleware support is available, adding access controls is as easy as passing explicit listener.options in your listeners:
...
+ listenerOptions = {"id":"someCommand","auth":"true","roles":"admins"}
- robot.hear /some command/, (msg) ->
+ robot.hear /some command/, listenerOptions, (msg) ->
# does some stuff
...
In some organizations multiple chatbots serving multiple environments (data centers, vpc, etc.) is convenient. Rather than having entirely custom chatbots for every environment, auth-middleware lets you declare that a particular chatbot should ignore any requests without auth-middleware configuration (HUBOT_AUTH_MIDDLEWARE_IGNORE_NO_AUTH=true environment variable). With this configuration, you can have a 'production' hubot and a 'stage1' hubot both running and listening in the same room, but only respond to a particular request from one bot.
listenerOptions = {"id":"restartDatabase","auth":"true","env":"stage1"}
# Never in prod!!!
robot.hear /restart (db|database)/, listenerOptions, (msg) ->
# Errors if env is non-stage1
#
# db restart logic...
msg.send "database restarted"
Custom roles support basic access control groups. If deploy, infrastructure, or other commands must be limited to particular users, assign all those users a role and declare that role as required for a given command listener.
listenerOptions = {"id":"deleteUser","auth":"true","roles":"mgmt"}
robot.hear /userDelete ([\w]+)/, listenerOptions, (msg) ->
# Errors if request.user is not in role mgmt
#
# userDelete logic...
msg.send "Deleted user msg.match[1]"
Room quarantines are helpful for lots of circumstances. Using auth-middleware room controls lets multiple bots listen wherever they want, but only respond to room-specific requests. For some bot-user/adapter configurations this is much easier than per-room quarantining at the adapter/user level.
listenerOptions = {"id":"youtubeSearches","auth":"true","rooms":"videosRoom"}
robot.hear /youtube me (.*)/, listenerOptions, (msg) ->
# Errors if the request is anywhere other than the 'videosRoom'
#
# Youtube video search...
msg.send videolink
hubot-auth-middleware writes event details to INFO logs for audit needs. Messages include the following:
These are the log outputs from the test suite. Note that I removed the timestamps for human-readability and to focus on the actual log message. Also, by default these are not displayed during testing (HUBOT_LOG_LEVEL='warning').
INFO auth-middleware: Accepting (without auth checks) 'amTest no options' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Accepting (without auth checks) 'amTest strange options' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Rejecting (env) 'amTest reject environment' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Rejecting (room) 'amTest reject room' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Rejecting (role) 'amTest reject role' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Accepting (valid auth) 'amTest allow environment' request from user: adminUser (1), room: #test, env: x
INFO auth-middleware: Accepting (valid auth) 'amTest allow room' request from user: otherUser (2), room: #x, env: x
INFO auth-middleware: Accepting (valid auth) 'amTest allow role' request from user: adminUser (1), room: #test, env: x
Test utilities are listed as devDependencies, and nvm is in place for nodejs version management. If you want to run tests or make updates, use:
nvm use
npm install
npm test
FAQs
Use roles, rooms, and envs to restrict command access in other scripts
The npm package hubot-auth-middleware-ext receives a total of 2 weekly downloads. As such, hubot-auth-middleware-ext popularity was classified as not popular.
We found that hubot-auth-middleware-ext 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.