2025-05-22 19:24:13 +00:00
# Existing Plugins
2025-06-28 03:08:09 +00:00
With the aMQTT plugins framework, one can add additional functionality without
having to rewrite core logic in the broker or client. Plugins can be loaded and configured using
the `plugins` section of the config file (or parameter passed to the class).
## Broker
By default, `EventLoggerPlugin` , `PacketLoggerPlugin` , `AnonymousAuthPlugin` and `BrokerSysPlugin` are activated
and configured for the broker:
2025-05-22 19:24:13 +00:00
2025-05-30 22:50:31 +00:00
```yaml
2025-06-28 03:08:09 +00:00
--8< -- " amqtt / scripts / default_broker . yaml "
2025-05-22 22:24:51 +00:00
```
2025-05-22 19:24:13 +00:00
2025-05-22 22:24:51 +00:00
2025-06-28 03:08:09 +00:00
??? warning "Loading plugins from EntryPoints in `pyproject.toml` has been deprecated"
Previously, all plugins were loaded from EntryPoints:
```toml
--8< -- " pyproject . toml:included "
```
2025-05-22 19:24:13 +00:00
2025-06-28 03:08:09 +00:00
But the same 4 plugins were activated in the previous default config:
```yaml
--8< -- " samples / legacy . yaml "
```
## Client
By default, the `PacketLoggerPlugin` is activated and configured for the client:
```yaml
--8< -- " amqtt / scripts / default_client . yaml "
```
## Plugins
### Anonymous (Auth Plugin)
`amqtt.plugins.authentication.AnonymousAuthPlugin`
2025-05-22 19:24:13 +00:00
2025-05-30 22:50:31 +00:00
**Configuration**
2025-05-22 22:24:51 +00:00
```yaml
2025-06-28 03:08:09 +00:00
plugins:
- ...
- amqtt.plugins.authentication.AnonymousAuthPlugin:
allow_anonymous: false
- ...
2025-05-22 19:24:13 +00:00
```
2025-05-28 11:45:12 +00:00
!!! danger
2025-06-28 03:08:09 +00:00
even if `allow_anonymous` is set to `false` , the plugin will still allow access if a username is provided by the client
2025-05-28 11:45:12 +00:00
2025-06-28 03:08:09 +00:00
??? warning "EntryPoint-style configuration is deprecated"
2025-05-28 11:45:12 +00:00
2025-06-28 03:08:09 +00:00
```yaml
auth:
plugins:
- auth_anonymous
allow-anonymous: true # if false, providing a username will allow access
```
2025-05-22 22:24:51 +00:00
2025-06-28 03:08:09 +00:00
### Password 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-30 22:50:31 +00:00
**Configuration**
2025-05-22 19:24:13 +00:00
```yaml
2025-06-28 03:08:09 +00:00
plugins:
- ...
- amqtt.plugins.authentication.FileAuthPlugin:
password_file: /path/to/password_file
- ...
2025-05-22 19:24:13 +00:00
```
2025-06-28 03:08:09 +00:00
??? warning "EntryPoint-style configuration is deprecated"
```yaml
auth:
plugins:
- auth_file
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
2025-06-28 03:08:09 +00:00
### Taboo (Topic Plugin)
2025-05-22 22:24:51 +00:00
2025-06-28 03:08:09 +00:00
`amqtt.plugins.topic_checking.TopicTabooPlugin`
2025-05-28 11:45:12 +00:00
2025-05-22 22:24:51 +00:00
Prevents using topics named: `prohibited` , `top-secret` , and `data/classified`
**Configuration**
```yaml
2025-06-28 03:08:09 +00:00
plugins:
- ...
- amqtt.plugins.topic_checking.TopicTabooPlugin:
- ...
2025-05-22 22:24:51 +00:00
```
2025-06-28 03:08:09 +00:00
??? warning "EntryPoint-style configuration is deprecated"
```yaml
topic-check:
enabled: true
plugins:
- topic_taboo
```
2025-05-22 22:24:51 +00:00
2025-06-28 03:08:09 +00:00
### ACL (Topic Plugin)
`amqtt.plugins.topic_checking.TopicAccessControlListPlugin`
2025-05-28 11:45:12 +00:00
2025-05-22 22:24:51 +00:00
**Configuration**
2025-06-28 03:08:09 +00:00
- `acl` *(mapping)* : determines subscription access; if `publish-acl` is not specified, determine both publish and subscription access.
2025-05-30 22:50:31 +00:00
The list should be a key-value pair, where:
`<username>:[<topic1>, <topic2>, ...]` *(string, list[string])* : username of the client followed by a list of allowed topics (wildcards are supported: `#` , `+` ).
2025-06-28 03:08:09 +00:00
- `publish-acl` *(mapping)* : determines publish access. This parameter defines the list of access control rules; each item is a key-value pair, where:
2025-05-30 22:50:31 +00:00
`<username>:[<topic1>, <topic2>, ...]` *(string, list[string])* : username of the client followed by a list of allowed topics (wildcards are supported: `#` , `+` ).
!!! info "Reserved usernames"
- The username `admin` is allowed access to all topics.
- The username `anonymous` will control allowed topics, if using the `auth_anonymous` plugin.
2025-05-22 22:24:51 +00:00
```yaml
2025-06-28 03:08:09 +00:00
plugins:
- ...
- amqtt.plugins.topic_checking.TopicAccessControlListPlugin:
publish_acl:
- username: ["list", "of", "allowed", "topics", "for", "publishing"]
acl:
- username: ["list", "of", "allowed", "topics", "for", "subscribing"]
- ...
2025-05-22 22:24:51 +00:00
```
2025-06-28 03:08:09 +00:00
??? warning "EntryPoint-style configuration is deprecated"
```yaml
topic-check:
enabled: true
plugins:
- topic_acl
publish-acl:
- username: ["list", "of", "allowed", "topics", "for", "publishing"]
- .
acl:
- username: ["list", "of", "allowed", "topics", "for", "subscribing"]
- .
```
### $SYS topics
2025-05-22 17:20:49 +00:00
2025-06-28 03:08:09 +00:00
`amqtt.plugins.sys.broker.BrokerSysPlugin`
2025-05-30 22:50:31 +00:00
2025-05-22 17:20:49 +00:00
Publishes, on a periodic basis, statistics about the broker
2025-05-30 22:50:31 +00:00
**Configuration**
2025-05-22 17:20:49 +00:00
- `sys_interval` - int, seconds between updates
2025-06-28 03:08:09 +00:00
```yaml
plugins:
- ...
- amqtt.plugins.sys.broker.BrokerSysPlugin:
sys_interval: 20 # int, seconds between updates
- ...
```
2025-05-22 17:20:49 +00:00
2025-05-30 22:50:31 +00:00
**Supported Topics**
2025-05-22 17:20:49 +00:00
2025-06-28 03:08:09 +00:00
- `$SYS/broker/version` *(string)*
- `$SYS/broker/load/bytes/received` *(int)*
- `$SYS/broker/load/bytes/sent` *(int)*
- `$SYS/broker/messages/received` *(int)*
- `$SYS/broker/messages/sent` *(int)*
- `$SYS/broker/time` *(int, current time in epoch seconds)*
- `$SYS/broker/uptime` *(int, seconds since broker start)*
- `$SYS/broker/uptime/formatted` *(string, start time of broker in UTC)*
- `$SYS/broker/clients/connected` *(int, number of currently connected clients)*
- `$SYS/broker/clients/disconnected` *(int, number of clients that have disconnected)*
- `$SYS/broker/clients/maximum` *(int, maximum number of clients connected)*
- `$SYS/broker/clients/total` *(int)*
- `$SYS/broker/messages/inflight` *(int)*
- `$SYS/broker/messages/inflight/in` *(int)*
- `$SYS/broker/messages/inflight/out` *(int)*
- `$SYS/broker/messages/inflight/stored` *(int)*
- `$SYS/broker/messages/publish/received` *(int)*
- `$SYS/broker/messages/publish/sent` *(int)*
- `$SYS/broker/messages/retained/count` *(int)*
- `$SYS/broker/messages/subscriptions/count` *(int)*
- `$SYS/broker/heap/size` *(float, MB)*
- `$SYS/broker/heap/maximum` *(float, MB)*
- `$SYS/broker/cpu/percent` *(float, %)*
- `$SYS/broker/cpu/maximum` *(float, %)*
### Event Logger
`amqtt.plugins.logging_amqtt.EventLoggerPlugin`
This plugin issues log messages when [broker and mqtt events ](custom_plugins.md#events ) are triggered:
- info level messages for `client connected` and `client disconnected`
- debug level for all others
### Packet Logger
`amqtt.plugins.logging_amqtt.PacketLoggerPlugin`
This plugin issues debug-level messages for [mqtt events ](custom_plugins.md#client-and-broker ): `on_mqtt_packet_sent`
and `on_mqtt_packet_received` .