Skip to content

Commit 3d237e5

Browse files
chore: update readme
1 parent c71bf4c commit 3d237e5

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# mqtt-broker-flashmq
2+
23
[FlashMQ](https://github.com/halfgaar/FlashMQ) fork includes plugin for auth with jwt token decode and verify.
34

45
### Purpose
6+
57
To authenticate a FlashMQ connection using a custom auth plugin that verifies a username (JWT token) against an RSA PEM key passed as a base64-encoded string via the `AUTH_PUBLICKEY` environment variable
68

79
### Local Build
10+
811
Its not straight-forward to compile a C/C++ FlashMQ code for a Mac processor so there is docker-compose.yml provided. To start Flashmq just type `docker-compose up --build --watch` in your favourite terminal for devlopment.
912
Also `devcontainer` can be attached to the running container for debugging. Line 36-38 in Docker file are updated to run the debug build for FlashMQ
1013
![Debug Build](./images/debug-build.png) </br>
@@ -13,13 +16,26 @@ and install gdb debug servers in the container</br>
1316
Once the container is running launch your favourite editors debug launch config
1417

1518
## Flash Config
19+
1620
If `allow_anonymous:false` then the plugin will expect `username` field to be not NULL and automatically authenticate.
1721
Thus `plugin` config is not be required to be mentioned as its already loaded the config from the correct path. Make sure if its mentioned the the path is `etc/flashmq/libplugin_libcurl.so` to use the plugin built with `mqtt-broker-flashmq` image.
18-
The docker image places the custom Auth plugin at path `etc/flashmq/libplugin_libcurl.so` and container will point to the plugin using the config from the image.
22+
The docker image places the custom Auth plugin at path `etc/flashmq/libplugin_libcurl.so` and container will point to the plugin using the config from the image.
1923

24+
| ENV VARS | default |
25+
| -------------- | --------- |
26+
| AUTH_PUBLICKEY | undefined |
2027

21-
|ENV VARS| default|
22-
|---------|--------|
23-
| AUTH_PUBLICKEY| undefined|
28+
### ACL caching
2429

30+
This plugin caches JWT authorization to make ACL checks fast and lock-free.
2531

32+
- Mapping is done as follows: `clientid` → JWT `exp` (epoch seconds) in a sharded, thread-safe `parallel_flat_hash_map` using parallel hashmap header only library.
33+
- On successful login JWT verification, the client's `exp` is stored.
34+
- On each ACL check (`flashmq_plugin_acl_check`), the cache is read:
35+
- Cache hit and not expired → allow.
36+
- Cache hit but expired → entry is erased and access is denied.
37+
- Cache miss → access is denied.
38+
- **Invalidation**:
39+
- On client disconnect, the `clientid` entry is erased.
40+
- On plugin shutdown, the entire cache is cleared.
41+
- if `now > exp`, the entry is removed during ACL check.

0 commit comments

Comments
 (0)