Skip to content

Commit 781af0c

Browse files
committed
Add feedback
1 parent b725188 commit 781af0c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
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

0 commit comments

Comments
 (0)