Skip to content

Commit 04335a4

Browse files
Merge pull request #290457 from PatAltimore/patricka-scrub-authorization-release-aio-ga
Add username clarification
2 parents 370f56f + fa0235c commit 04335a4

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ resource myBrokerAuthentication 'Microsoft.IoTOperations/instances/brokers/authe
240240
{
241241
method: 'X509'
242242
x509Settings: {
243+
trustedClientCaCert: 'client-ca'
243244
authorizationAttributes: {
244245
root: {
245246
attributes: {
@@ -303,8 +304,8 @@ spec:
303304
- my-audience
304305
- method: X509
305306
x509Settings:
307+
trustedClientCaCert: client-ca
306308
authorizationAttributes:
307-
trustedClientCaCert: client-ca
308309
root:
309310
attributes:
310311
organization: contoso

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
7878
rules: [
7979
{
8080
principals: {
81-
usernames: [
81+
clientIds: [
8282
'temperature-sensor'
8383
'humidity-sensor'
8484
]
@@ -96,7 +96,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
9696
{
9797
method: 'Publish'
9898
topics: [
99-
'/telemetry/{principal.username}'
99+
'/telemetry/{principal.clientId}'
100100
'/telemetry/{principal.attributes.organization}'
101101
]
102102
}
@@ -134,7 +134,7 @@ spec:
134134
cache: Enabled
135135
rules:
136136
- principals:
137-
usernames:
137+
clientIds:
138138
- "temperature-sensor"
139139
- "humidity-sensor"
140140
attributes:
@@ -144,7 +144,7 @@ spec:
144144
- method: Connect
145145
- method: Publish
146146
topics:
147-
- "/telemetry/{principal.username}"
147+
- "/telemetry/{principal.clientId}"
148148
- "/telemetry/{principal.attributes.organization}"
149149
- method: Subscribe
150150
topics:
@@ -155,17 +155,27 @@ To create this *BrokerAuthorization* resource, apply the YAML manifest to your K
155155
156156
---
157157
158-
This broker authorization allows clients with usernames `temperature-sensor` or `humidity-sensor`, or clients with attributes `organization` with value `contoso` and `city` with value `seattle`, to:
158+
This broker authorization allows clients with client IDs `temperature-sensor` or `humidity-sensor`, or clients with attributes `organization` with value `contoso` and `city` with value `seattle`, to:
159159

160160
- Connect to the broker.
161-
- Publish messages to telemetry topics scoped with their usernames and organization. For example:
161+
- Publish messages to telemetry topics scoped with their client IDs and organization. For example:
162162
- `temperature-sensor` can publish to `/telemetry/temperature-sensor` and `/telemetry/contoso`.
163163
- `humidity-sensor` can publish to `/telemetry/humidity-sensor` and `/telemetry/contoso`.
164164
- `some-other-username` can publish to `/telemetry/contoso`.
165165
- Subscribe to commands topics scoped with their organization. For example:
166166
- `temperature-sensor` can subscribe to `/commands/contoso`.
167167
- `some-other-username` can subscribe to `/commands/contoso`.
168168

169+
### Using username for authorization
170+
171+
To use the MQTT username for authorization, specify them as an array under `principals.usernames`. However, depending on the authentication method, the username might not be verified:
172+
173+
- **Kubernetes SAT** - Username shouldn't be used for authorization because it's not verified for MQTTv5 with enhanced authentication.
174+
- **X.509** - Username matches the CN from certificate and can be used for authorization rules.
175+
- **Custom** - Username should only be used for authorization rules if custom authentication validates the username.
176+
177+
To prevent security issues, only use the MQTT username for broker authorization when it can be verified.
178+
169179
### Further limit access based on client ID
170180

171181
Because the `principals` field is a logical OR, you can further restrict access based on client ID by adding the `clientIds` field to the `brokerResources` field. For example, to allow clients with client IDs that start with its building number to connect and publish telemetry to topics scoped with their building, use the following configuration:

0 commit comments

Comments
 (0)