2025-05-22 19:24:13 +00:00
|
|
|
# Existing Plugins
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
With the aMQTT Broker plugins framework, one can add additional functionality without
|
|
|
|
having to rewrite core logic. The list of plugins that get loaded are specified in `pyproject.toml`;
|
|
|
|
each plugin can then check the configuration to determine how to behave (including disabling).
|
2025-05-22 19:24:13 +00:00
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
```toml
|
|
|
|
[project.entry-points."amqtt.broker.plugins"]
|
|
|
|
plugin_alias = "module.submodule.file:ClassName"
|
|
|
|
```
|
2025-05-22 19:24:13 +00:00
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
## auth_anonymous (Auth Plugin)
|
|
|
|
|
|
|
|
`amqtt.plugins.authentication:AnonymousAuthPlugin`
|
2025-05-22 19:24:13 +00:00
|
|
|
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
**Config Options**
|
|
|
|
|
|
|
|
```yaml
|
2025-05-22 19:24:13 +00:00
|
|
|
auth:
|
2025-05-22 22:24:51 +00:00
|
|
|
plugins:
|
|
|
|
- auth_anonymous
|
2025-05-28 11:45:12 +00:00
|
|
|
allow-anonymous: true # if false, providing a username will allow access
|
2025-05-22 19:24:13 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
2025-05-28 11:45:12 +00:00
|
|
|
!!! danger
|
|
|
|
even if `allow-anonymous` is set to `false`, the plugin will still allow access if a username is provided by the client
|
|
|
|
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
## auth_file (Auth Plugin)
|
|
|
|
|
|
|
|
`amqtt.plugins.authentication:FileAuthPlugin`
|
2025-05-22 19:24:13 +00:00
|
|
|
|
|
|
|
clients are authorized by providing username and password, compared against file
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
**Config Options**
|
2025-05-22 19:24:13 +00:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
|
|
|
auth:
|
2025-05-22 22:24:51 +00:00
|
|
|
plugins:
|
|
|
|
- auth_file
|
2025-05-22 19:24:13 +00:00
|
|
|
password-file: /path/to/password_file
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
**File Format**
|
2025-05-22 19:24:13 +00:00
|
|
|
|
|
|
|
The file includes `username:password` pairs, one per line.
|
|
|
|
|
|
|
|
The password should be encoded using sha-512 with `mkpasswd -m sha-512` or:
|
|
|
|
|
|
|
|
```python
|
|
|
|
import sys
|
|
|
|
from getpass import getpass
|
|
|
|
from passlib.hash import sha512_crypt
|
|
|
|
|
|
|
|
passwd = input() if not sys.stdin.isatty() else getpass()
|
|
|
|
print(sha512_crypt.hash(passwd))
|
|
|
|
```
|
2025-05-22 22:24:51 +00:00
|
|
|
|
|
|
|
## Taboo (Topic Plugin)
|
|
|
|
|
2025-05-28 11:45:12 +00:00
|
|
|
`amqtt.plugins.topic_checking:TopicTabooPlugin`
|
|
|
|
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
Prevents using topics named: `prohibited`, `top-secret`, and `data/classified`
|
|
|
|
|
|
|
|
**Configuration**
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
topic-check:
|
|
|
|
enabled: true
|
|
|
|
plugins:
|
|
|
|
- topic_taboo
|
|
|
|
```
|
|
|
|
|
|
|
|
## ACL (Topic Plugin)
|
|
|
|
|
2025-05-28 11:45:12 +00:00
|
|
|
`amqtt.plugins.topic_checking:TopicAccessControlListPlugin`
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
**Configuration**
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
topic-check:
|
|
|
|
enabled: true
|
|
|
|
plugins:
|
|
|
|
- topic_acl
|
2025-05-28 11:45:12 +00:00
|
|
|
publish-acl:
|
|
|
|
- username: ["list", "of", "allowed", "topics", "for", "publishing"]
|
|
|
|
- .
|
2025-05-22 22:24:51 +00:00
|
|
|
acl:
|
2025-05-28 11:45:12 +00:00
|
|
|
- username: ["list", "of", "allowed", "topics", "for", "subscribing"]
|
2025-05-22 22:24:51 +00:00
|
|
|
- .
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-22 19:24:13 +00:00
|
|
|
## Plugin: $SYS
|
2025-05-22 17:20:49 +00:00
|
|
|
|
|
|
|
Publishes, on a periodic basis, statistics about the broker
|
|
|
|
|
2025-05-22 22:24:51 +00:00
|
|
|
**Config Options**
|
2025-05-22 17:20:49 +00:00
|
|
|
|
|
|
|
- `sys_interval` - int, seconds between updates
|
|
|
|
|
|
|
|
### Supported Topics
|
|
|
|
|
2025-05-30 16:03:28 +00:00
|
|
|
- `$SYS/broker/load/bytes/received` - payload: `data`, int
|
|
|
|
- `$SYS/broker/load/bytes/sent` - payload: `data`, int
|
2025-05-22 17:20:49 +00:00
|
|
|
- `$SYS/broker/messages/received` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/sent` - payload: `data`, int
|
2025-05-22 19:24:13 +00:00
|
|
|
- `$SYS/broker/time` - payload: `data`, int (current time, epoch seconds)
|
|
|
|
- `$SYS/broker/uptime` - payload: `data`, int (seconds since broker start)
|
|
|
|
- `$SYS/broker/uptime/formatted` - payload: `data`, datetime (start time of broker in UTC)
|
2025-05-22 17:20:49 +00:00
|
|
|
- `$SYS/broker/clients/connected` - payload: `data`, int
|
|
|
|
- `$SYS/broker/clients/disconnected` - payload: `data`, int
|
|
|
|
- `$SYS/broker/clients/maximum` - payload: `data`, int
|
|
|
|
- `$SYS/broker/clients/total` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/inflight` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/inflight/in` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/inflight/out` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/inflight/stored` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/publish/received` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/publish/sent` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/retained/count` - payload: `data`, int
|
|
|
|
- `$SYS/broker/messages/subscriptions/count` - payload: `data`, int
|