rmqtt-acl
File-based Access Control List plugin. Evaluates allow/deny rules to control client publish and subscribe access by user, IP address, client ID, and topic filter patterns.
Overview
Rules are evaluated in order — the first matching rule determines the result. If no rule matches, access is denied by default. The plugin registers 5 hook callbacks covering authentication, ACL checks, and client lifecycle events.
Usage
Build
Add the dependency in rmqttd/Cargo.toml:
= "0.21"
Or enable via the rmqtt-plugins meta-crate:
= { = "0.21", = ["acl"] }
Register
register.await?;
// or with explicit name:
register_named.await?;
Parameters: (scx, default_startup, immutable).
Configuration
File: rmqtt-acl.toml (in the plugin config directory)
# Disconnect if publishing is rejected
= true
= [
["allow", { = "dashboard" }, "subscribe", ["$SYS/#"]],
[ { ipaddr = "127.0.0.1" }, "pubsub", ["$SYS/#", "#"]],
[ "all", "subscribe", ["$SYS/#", { eq = "#" }]],
[ "all"]
]
Rule Format
["allow" | "deny", <who>, <action>, <topics>]
<who> (matcher):
| Format | Description |
|---|---|
"all" |
Match any client |
{ user = "username" } |
Match by username |
{ ipaddr = "127.0.0.1" } |
Match by IP address |
{ clientid = "client123" } |
Match by client ID |
<action>:
| Value | Description |
|---|---|
"subscribe" |
Subscribe only |
"publish" |
Publish only |
"pubsub" |
Both subscribe and publish |
<topics>: A list of topic filters. Supports { eq = "exact/topic" } for exact match.
Config Options
| Option | Type | Default | Description |
|---|---|---|---|
disconnect_if_pub_rejected |
bool |
true |
Disconnect client when publish is denied |
rules |
array |
— | Ordered list of ACL rules |
Configuration Source
The plugin loads config via scx.plugins.load_config_default::<PluginConfig>("rmqtt-acl"), supporting:
{plugins.dir}/rmqtt-acl.toml(file, optional — uses defaults if missing)rmqtt_plugin_rmqtt_acl_*environment variables- Inline config via
ServerContext::plugins_config_map_add()
Hook Callbacks
| Hook Type | Purpose |
|---|---|
ClientConnected |
Pre-compute topic placeholders (%c, %u) and ACL rules per client |
ClientDisconnected |
Clean up per-client cached topic filters |
ClientAuthenticate |
Verify username/password against ACL rules |
ClientSubscribeCheckAcl |
Check subscribe ACL, return SubscribeAclResult |
MessagePublishCheckAcl |
Check publish ACL, return PublishAclResult |
Dependencies
rmqtt (feature plugin), serde, tokio, async-trait, log, serde_json, ahash, bytestring
License
MIT OR Apache-2.0