Skip to content

Commit 0f4288e

Browse files
Merge pull request #281951 from PatAltimore/patricka-expired-creds-release-aio-july-updates
Add MQTT broker client disconnect on expiration
2 parents 192acea + d2daec1 commit 0f4288e

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

articles/iot-operations/create-edge-apps/howto-develop-mqttnet-apps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
2929
var mqttClient = mqttFactory.CreateMqttClient();
3030
```
3131

32-
1. The following Kubernetes pod specification mounts the service account token to the specified path on the container file system. The mounted token is used as the password with well-known username `$sat`:
32+
1. The following Kubernetes pod specification mounts the service account token to the specified path on the container file system. The mounted token is used as the password with well-known username `K8S-SAT`:
3333

3434
```csharp
3535
string token_path = "/var/run/secrets/tokens/mqtt-client-token";
@@ -51,7 +51,7 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
5151
.WithTcpServer(broker, 1883)
5252
.WithProtocolVersion(MqttProtocolVersion.V500)
5353
.WithClientId("sampleid")
54-
.WithCredentials("$sat", satToken)
54+
.WithCredentials("K8S-SAT", satToken)
5555
.Build();
5656
```
5757

articles/iot-operations/create-edge-apps/tutorial-event-driven-with-dapr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ To verify the MQTT bridge is working, deploy an MQTT client to the cluster.
211211
1. Subscribe to the `sensor/window_data` topic to observe the published output from the Dapr application:
212212

213213
```bash
214-
mosquitto_sub -L mqtts://aio-mq-dmqtt-frontend/sensor/window_data -u '$sat' -P $(cat /var/run/secrets/tokens/mqtt-client-token) --cafile /var/run/certs/aio-mq-ca-cert/ca.crt
214+
mosquitto_sub -L mqtts://aio-mq-dmqtt-frontend/sensor/window_data -u 'K8S-SAT' -P $(cat /var/run/secrets/tokens/mqtt-client-token) --cafile /var/run/certs/aio-mq-ca-cert/ca.crt
215215
```
216216

217217
1. Verify the application is outputting a sliding windows calculation for the various sensors every 10 seconds:

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.subservice: azure-mqtt-broker
77
ms.topic: how-to
88
ms.custom:
99
- ignite-2023
10-
ms.date: 07/16/2024
10+
ms.date: 07/26/2024
1111

1212
#CustomerIntent: As an operator, I want to configure authentication so that I have secure MQTT broker communications.
1313
---
@@ -56,7 +56,7 @@ BrokerListener and BrokerAuthentication are separate resources, but they're link
5656

5757
The order of authentication methods in the array determines how MQTT broker authenticates clients. MQTT broker tries to authenticate the client's credentials using the first specified method and iterates through the array until it finds a match or reaches the end.
5858

59-
For each method, MQTT broker first checks if the client's credentials are *relevant* for that method. For example, SAT authentication requires a username starting with `$sat`, and X.509 authentication requires a client certificate. If the client's credentials are relevant, MQTT broker then verifies if they're valid. For more information, see the [Configure authentication method](#configure-authentication-method) section.
59+
For each method, MQTT broker first checks if the client's credentials are *relevant* for that method. For example, SAT authentication requires a username starting with `K8S-SAT`, and X.509 authentication requires a client certificate. If the client's credentials are relevant, MQTT broker then verifies if they're valid. For more information, see the [Configure authentication method](#configure-authentication-method) section.
6060

6161
For custom authentication, MQTT broker treats failure to communicate with the custom authentication server as *credentials not relevant*. This behavior lets MQTT broker fall back to other methods if the custom server is unreachable.
6262

@@ -92,7 +92,7 @@ The earlier example specifies custom and SAT. When a client connects, MQTT broke
9292

9393
1. If the custom authentication server responds with `Pass` or `Fail` result, the authentication flow ends. However, if the custom authentication server isn't available, then MQTT broker falls back to the remaining specified methods, with SAT being next.
9494

95-
1. MQTT broker tries to authenticate the credentials as SAT credentials. If the MQTT username starts with `$sat`, MQTT broker evaluates the MQTT password as a SAT.
95+
1. MQTT broker tries to authenticate the credentials as SAT credentials. If the MQTT username starts with `K8S-SAT`, MQTT broker evaluates the MQTT password as a SAT.
9696

9797
If the custom authentication server is unavailable and all subsequent methods determined that the provided credentials aren't relevant, then the broker denies the client connection.
9898

@@ -386,6 +386,25 @@ spec:
386386
header_key: header_value
387387
```
388388

389+
## Client disconnect after credentials expire
390+
391+
MQTT broker disconnects clients when their credentials expire. Disconnect after credential expiration applies to all clients that connect to the MQTT broker frontends including:
392+
393+
- Clients authenticated with SATs disconnect when their SAT expires
394+
- Clients authenticated with X.509 disconnect when their client certificate expires
395+
- Clients authenticated with custom authentication disconnect based on the expiry time returned from the custom authentication server.
396+
397+
On disconnect, the client's network connection is closed. The client won't receive an MQTT DISCONNECT packet, but the broker logs a message that it disconnected the client.
398+
399+
MQTT v5 clients authenticated with SATs and custom authentication can reauthenticate with a new credential before their initial credential expires. X.509 clients cannot reauthenticate and must re-establish the connection since authentication is done at the TLS layer.
400+
401+
Clients can reauthenticate by sending an MQTT v5 AUTH packet.
402+
403+
SAT clients send an AUTH client with the fields `method: K8S-SAT`, `data: <token>`.
404+
Custom authentication clients set the method and data field as required by the custom authentication server.
405+
406+
Successful reauthentication updates the client's credential expiry with the expiry time of its new credential, and the broker responds with a *Success AUTH* packet. Failed authentication due to transient issues cause the broker to respond with a *ContinueAuthentication AUTH* packet. For example, the custom authentication server being unavailable. The client can try again later. Other authentication failures cause the broker to send a DISCONNECT packet and close the client's network connection.
407+
389408
## Related content
390409

391410
- About [BrokerListener resource](howto-configure-brokerlistener.md)

0 commit comments

Comments
 (0)