You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FlashMQ](https://github.com/halfgaar/FlashMQ) fork includes plugin for auth with jwt token decode and verify.
3
4
4
5
### Purpose
6
+
5
7
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
6
8
7
9
### Local Build
10
+
8
11
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.
9
12
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
10
13
 </br>
@@ -13,13 +16,26 @@ and install gdb debug servers in the container</br>
13
16
Once the container is running launch your favourite editors debug launch config
14
17
15
18
## Flash Config
19
+
16
20
If `allow_anonymous:false` then the plugin will expect `username` field to be not NULL and automatically authenticate.
17
21
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.
19
23
24
+
| ENV VARS | default |
25
+
| -------------- | --------- |
26
+
| AUTH_PUBLICKEY | undefined |
20
27
21
-
|ENV VARS| default|
22
-
|---------|--------|
23
-
| AUTH_PUBLICKEY| undefined|
28
+
### ACL caching
24
29
30
+
This plugin caches JWT authorization to make ACL checks fast and lock-free.
25
31
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