Skip to content

Commit ba924f4

Browse files
Merge pull request #281917 from PatAltimore/patricka-enhanced-auth-release-aio-july-updates
Change MQTT client to enhanced auth
2 parents e8e79e0 + 781af0c commit ba924f4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

articles/iot-operations/manage-mqtt-broker/howto-configure-authentication.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ Apply your changes with `kubectl apply`. It might take a few minutes for the cha
277277

278278
### Test SAT authentication
279279

280-
SAT authentication must be used from a client in the same cluster as MQTT broker. The following command specifies a pod that has the mosquitto client and mounts the SAT created in the previous steps into the pod.
280+
SAT authentication must be used from a client in the same cluster as MQTT broker. Only enhanced authentication fields are permitted. Set authentication method to `K8S-SAT` and authentication data to the token.
281+
282+
The following command specifies a pod that has the mosquitto client and mounts the SAT created in the previous steps into the pod.
281283

282284
```yaml
283285
apiVersion: v1
@@ -306,21 +308,28 @@ spec:
306308

307309
Here, the `serviceAccountName` field in the pod configuration must match the service account associated with the token being used. Also, The `serviceAccountToken.audience` field in the pod configuration must be one of the `audiences` configured in the BrokerAuthentication resource.
308310

309-
Once the pod has been created, start a shell in the pod:
311+
Once the pod is created, start a shell in the pod:
310312

311313
```bash
312314
kubectl exec --stdin --tty mqtt-client -n azure-iot-operations -- sh
313315
```
314316

315-
The token is mounted at the path specified in the configuration `/var/run/secrets/tokens` in the previous example. Retrieve the token and use it to authenticate.
317+
Inside the pod's shell, run the following command to publish a message to the broker:
316318

317319
```bash
318-
token=$(cat /var/run/secrets/tokens/mqtt-client-token)
320+
mosquitto_pub --host aio-mq-dmqtt-frontend --port 8883 --message "hello" --topic "world" --debug --cafile /var/run/certs/ca.crt -D CONNECT authentication-method 'K8S-SAT' -D CONNECT authentication-data $(cat /var/run/secrets/tokens/mq-sat)
321+
```
322+
323+
The output should look similar to the following:
319324

320-
mosquitto_pub -h aio-mq-dmqtt-frontend -V mqttv5 -t hello -m world -u '$sat' -P "$token"
325+
```Output
326+
Client (null) sending CONNECT
327+
Client (null) received CONNACK (0)
328+
Client (null) sending PUBLISH (d0, q0, r0, m1, 'world', ... (5 bytes))
329+
Client (null) sending DISCONNECT
321330
```
322331

323-
The MQTT username must be set to `$sat`. The MQTT password must be set to the SAT itself.
332+
The mosquitto client uses the service account token mounted at `/var/run/secrets/tokens/mq-sat` to authenticate with the broker. The token is valid for 24 hours. The client also uses the default root CA cert mounted at `/var/run/certs/ca.crt` to verify the broker's TLS certificate chain.
324333

325334
### Refresh service account tokens
326335

articles/iot-operations/manage-mqtt-broker/howto-test-connection.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The first option is to connect from within the cluster. This option uses the def
8787
1. Inside the pod's shell, run the following command to publish a message to the broker:
8888

8989
```console
90-
mosquitto_pub --host aio-mq-dmqtt-frontend --port 8883 --message "hello" --topic "world" --username '$sat' --pw $(cat /var/run/secrets/tokens/mq-sat) --debug --cafile /var/run/certs/ca.crt
90+
mosquitto_pub --host aio-mq-dmqtt-frontend --port 8883 --message "hello" --topic "world" --debug --cafile /var/run/certs/ca.crt -D CONNECT authentication-method 'K8S-SAT' -D CONNECT authentication-data $(cat /var/run/secrets/tokens/mq-sat)
9191
```
9292

9393
The output should look similar to the following:
@@ -104,7 +104,7 @@ The first option is to connect from within the cluster. This option uses the def
104104
1. To subscribe to the topic, run the following command:
105105

106106
```console
107-
mosquitto_sub --host aio-mq-dmqtt-frontend --port 8883 --topic "world" --username '$sat' --pw $(cat /var/run/secrets/tokens/mq-sat) --debug --cafile /var/run/certs/ca.crt
107+
mosquitto_sub --host aio-mq-dmqtt-frontend --port 8883 --topic "world" --debug --cafile /var/run/certs/ca.crt -D CONNECT authentication-method 'K8S-SAT' -D CONNECT authentication-data $(cat /var/run/secrets/tokens/mq-sat)
108108
```
109109

110110
The output should look similar to the following:
@@ -119,15 +119,6 @@ The first option is to connect from within the cluster. This option uses the def
119119

120120
The mosquitto client uses the same service account token and root CA cert to authenticate with the broker and subscribe to the topic.
121121

122-
1. You can also use mqttui to connect to the broker using the service account token. The `--insecure` flag is required because mqttui doesn't support TLS certificate chain verification with a custom root CA cert.
123-
124-
> [!CAUTION]
125-
> Using `--insecure` is not recommended for production scenarios. Only use it for testing or development purposes.
126-
127-
```console
128-
mqttui --broker mqtts://aio-mq-dmqtt-frontend:8883 --username '$sat' --password $(cat /var/run/secrets/tokens/mq-sat) --insecure
129-
```
130-
131122
1. To remove the pod, run `kubectl delete pod mqtt-client -n azure-iot-operations`.
132123

133124
## Connect clients from outside the cluster to default the TLS port

0 commit comments

Comments
 (0)