Skip to content

Commit f405a11

Browse files
authored
Change principals to be client IDs also
1 parent 72c5299 commit f405a11

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 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
]
@@ -134,7 +134,7 @@ spec:
134134
cache: Enabled
135135
rules:
136136
- principals:
137-
usernames:
137+
clientIds:
138138
- "temperature-sensor"
139139
- "humidity-sensor"
140140
attributes:
@@ -155,10 +155,10 @@ 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`.
@@ -168,12 +168,14 @@ This broker authorization allows clients with usernames `temperature-sensor` or
168168

169169
### Using username for authorization
170170

171-
Here's a summary of how the username is used for authorization based on the authentication method:
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:
172172

173173
- **Kubernetes SAT** - Username shouldn't be used for authorization because is not verified for MQTTv5 with enhanced authentication.
174174
- **X.509** - Username matches the CN from certificate and can be used for authorization rules.
175175
- **Custom** - Username should only be used for authorization rules if custom authentication validates the username.
176176

177+
To prevent security issues, only use the MQTT username for broker authorization when it can be verified.
178+
177179
### Further limit access based on client ID
178180

179181
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)