Skip to content

Commit 04c1077

Browse files
committed
edit pass: mqtt-broker-batch2
1 parent 498cb3c commit 04c1077

File tree

1 file changed

+51
-45
lines changed

1 file changed

+51
-45
lines changed

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

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Authorization policies determine what actions the clients can perform on the bro
2121

2222
## Link BrokerAuthorization to BrokerListener
2323

24-
To link a *BrokerListener* to a *BrokerAuthorization* resource, specify the `authorizationRef` field in the `ports` setting of the *BrokerListener* resource. Similar to BrokerAuthentication, the *BrokerAuthorization* resource can be linked to multiple *BrokerListener* ports. The authorization policies apply to all linked listener ports. However, there's one key difference compared with BrokerAuthentication:
24+
To link a *BrokerListener* to a *BrokerAuthorization* resource, specify the `authorizationRef` field in the `ports` setting of the *BrokerListener* resource. Similar to BrokerAuthentication, the *BrokerAuthorization* resource can be linked to multiple *BrokerListener* ports. The authorization policies apply to all linked listener ports. There's one key difference compared with BrokerAuthentication:
2525

2626
> [!IMPORTANT]
2727
> To have the *BrokerAuthorization* configuration apply to a listener port, at least one BrokerAuthentication must also be linked to that listener port.
@@ -30,18 +30,18 @@ To learn more about *BrokerListener*, see [BrokerListener resource](howto-config
3030

3131
## Authorization rules
3232

33-
To configure authorization, create a *BrokerAuthorization* resource in your Kubernetes cluster. The following sections provide examples of how to configure authorization for clients that use usernames, attributes, X.509 certificates, and Kubernetes Service Account Tokens (SATs). For a list of the available settings, see the [Broker Authorization](/rest/api/iotoperations/broker-authorization) API reference.
33+
To configure authorization, create a *BrokerAuthorization* resource in your Kubernetes cluster. The following sections provide examples of how to configure authorization for clients that use usernames, attributes, X.509 certificates, and Kubernetes service account tokens (SATs). For a list of the available settings, see the [Broker Authorization](/rest/api/iotoperations/broker-authorization) API reference.
3434

35-
The following example shows how to create a *BrokerAuthorization* resource using both usernames and attributes:
35+
The following example shows how to create a *BrokerAuthorization* resource by using both usernames and attributes.
3636

3737
# [Portal](#tab/portal)
3838

39-
1. In the Azure portal, navigate to your IoT Operations instance.
39+
1. In the Azure portal, go to your IoT Operations instance.
4040
1. Under **Components**, select **MQTT Broker**.
4141
1. Select the **Authorization** tab.
4242
1. Choose an existing authentication policy or create a new one by selecting **Create authorization policy**.
4343

44-
:::image type="content" source="media/howto-configure-authorization/authorization-rules.png" alt-text="Screenshot using Azure portal to create broker authorization rules.":::
44+
:::image type="content" source="media/howto-configure-authorization/authorization-rules.png" alt-text="Screenshot that shows using the Azure portal to create broker authorization rules.":::
4545

4646
# [Bicep](#tab/bicep)
4747

@@ -115,7 +115,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
115115
116116
```
117117

118-
Deploy the Bicep file using Azure CLI.
118+
Deploy the Bicep file by using the Azure CLI:
119119

120120
```azurecli
121121
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -155,30 +155,30 @@ To create this *BrokerAuthorization* resource, apply the YAML manifest to your K
155155
156156
---
157157
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:
158+
This broker authorization allows clients with the client IDs `temperature-sensor` or `humidity-sensor`, or clients with the attributes `organization`, with the values `contoso` and `city`, and with the value `seattle`, to:
159159

160160
- Connect to the broker.
161161
- 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`.
165-
- Subscribe to commands topics scoped with their organization. For example:
165+
- Subscribe to command 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
169+
### Use a username for authorization
170170

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:
171+
To use the MQTT username for authorization, specify them as an array under `principals.usernames`. Depending on the authentication method, the username might not be verified:
172172

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.
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 common name (CN) from a certificate and can be used for authorization rules.
175+
- **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.
177+
To prevent security issues, use the MQTT username for broker authorization only when it can be verified.
178178

179179
### Further limit access based on client ID
180180

181-
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:
181+
Because the `principals` field is a logical `OR`, you can further restrict access based on client IDs by adding the `clientIds` field to the `brokerResources` field. For example, to allow clients with client IDs that start with their building number to connect and publish telemetry to topics scoped with their building, use the following configuration:
182182

183183
# [Portal](#tab/portal)
184184

@@ -282,7 +282,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
282282
}
283283
```
284284

285-
Deploy the Bicep file using Azure CLI.
285+
Deploy the Bicep file by using the Azure CLI:
286286

287287
```azurecli
288288
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -315,37 +315,37 @@ spec:
315315

316316
---
317317

318-
Here, if the `clientIds` weren't set under the `Connect` method, a client with any client ID could connect as long as it had the `building` attribute set to `building22` or `building23`. By adding the `clientIds` field, only clients with client IDs that start with `building22` or `building23` can connect. This ensures not only that the client has the correct attribute but also that the client ID matches the expected pattern.
318+
Here, if the `clientIds` weren't set under the `Connect` method, a client with any client ID could connect as long as it had the `building` attribute set to `building22` or `building23`. When you add the `clientIds` field, only clients with client IDs that start with `building22` or `building23` can connect. This designation ensures that the client has the correct attribute and that the client ID matches the expected pattern.
319319

320320
## Authorize clients that use X.509 authentication
321321

322-
Clients that use [X.509 certificates for authentication](./howto-configure-authentication.md) can be authorized to access resources based on X.509 properties present on their certificate or their issuing certificates up the chain.
322+
You can authorize clients that use [X.509 certificates for authentication](./howto-configure-authentication.md) to access resources based on X.509 properties present on their certificate or their issuing certificates up the chain.
323323

324-
### Using attributes
324+
### Use attributes
325325

326326
To create rules based on properties from a client's certificate, its root CA, or intermediate CA, define the X.509 attributes in the *BrokerAuthorization* resource. For more information, see [Certificate attributes](howto-configure-authentication.md#optional-certificate-attributes-for-authorization).
327327

328328
### With client certificate subject common name as username
329329

330-
To create authorization policies based on the *client* certificate subject common name (CN) only, create rules based on the CN.
330+
To create authorization policies based on the *client* certificate subject CN only, create rules based on the CN.
331331

332-
For example, if a client has a certificate with subject `CN = smart-lock`, its username is `smart-lock`. From there, create authorization policies as normal.
332+
For example, if a client has a certificate with the subject `CN = smart-lock`, its username is `smart-lock`. From there, create authorization policies as normal.
333333

334-
## Authorize clients that use Kubernetes Service Account Tokens
334+
## Authorize clients that use Kubernetes service account tokens
335335

336-
Authorization attributes for SATs are set as part of the [Service Account annotations](./howto-configure-authentication.md#kubernetes-service-account-tokens). For example, to add an authorization attribute named `group` with value `authz-sat`, run the command:
336+
Authorization attributes for SATs are set as part of the [service account annotations](./howto-configure-authentication.md#kubernetes-service-account-tokens). For example, to add an authorization attribute named `group` with the value `authz-sat`, run the command:
337337

338338
```bash
339339
kubectl annotate serviceaccount mqtt-client aio-broker-auth/group=authz-sat
340340
```
341341

342342
Attribute annotations must begin with `aio-broker-auth/` to distinguish them from other annotations.
343343

344-
As the application has an authorization attribute called `authz-sat`, there's no need to provide a `clientId` or `username`. The corresponding *BrokerAuthorization* resource uses this attribute as a principal, for example:
344+
As the application has an authorization attribute called `authz-sat`, there's no need to provide a `clientId` or `username` value. The corresponding *BrokerAuthorization* resource uses this attribute as a principal, for example:
345345

346346
# [Portal](#tab/portal)
347347

348-
In the Broker authorization rules for your authorization policy, use the following configuration:
348+
In the broker authorization rules for your authorization policy, use the following configuration:
349349

350350
```json
351351
[
@@ -447,7 +447,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
447447
448448
```
449449

450-
Deploy the Bicep file using Azure CLI.
450+
Deploy the Bicep file by using the Azure CLI:
451451

452452
```azurecli
453453
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -493,8 +493,8 @@ To set up authorization for clients that use the state store, provide the follow
493493

494494
### State store keys
495495

496-
The state store is accessed over the MQTT broker on topic `statestore/v1/FA9AE35F-2F64-47CD-9BFF-08E2B32A0FE8/command/invoke`.
497-
Since clients have access to the topic, you can specify keys and access levels under the `stateStoreResources` section of the MQTT broker `brokerResources` configuration.
496+
The state store is accessed over MQTT broker on the topic `statestore/v1/FA9AE35F-2F64-47CD-9BFF-08E2B32A0FE8/command/invoke`.
497+
Because clients have access to the topic, you can specify keys and access levels under the `stateStoreResources` section of the MQTT broker `brokerResources` configuration.
498498

499499
The `stateStoreResources` section format consists of access level, a pattern indicator, and the pattern.
500500

@@ -551,33 +551,39 @@ stateStoreResources:
551551

552552
---
553553

554-
The `method` field specifies the access level.
555-
- Read access is specified with `read`, write access with `write`, and both with `readwrite`.
554+
The `method` field specifies the access level:
555+
556+
- Read access is specified with `read`. Write access is specified with `write`. Read and write access is specified with `readwrite`.
556557
- Access level is required.
557558
- Read access level implies the actions of `get` and `keynotify`.
558559
- Write access level implies the actions of `set`, `del`, and `vdel`.
559560

560-
The `keyType` field specifies the type of key matching.
561-
- `pattern` to use *glob* style pattern matching
562-
- `string` to do exact match, for example when a key contains characters that might be otherwise matched as a pattern (`*`, `?`, `[0-9]`)
563-
- `binary` to match a binary key
561+
The `keyType` field specifies the type of key matching:
562+
563+
- `pattern`: Used for *Glob* style pattern matching.
564+
- `string`: Used to do exact match, for example, when a key contains characters that might be otherwise matched as a pattern (`*`, `?`, `[0-9]`).
565+
- `binary`: Used to match a binary key.
566+
567+
The `keys` field specifies the keys to match. You can specify the keys as *Glob* style patterns, token substitutions, or exact strings.
564568

565-
The `keys` field specifies the keys to match. The keys can be specified as *Glob* style patterns, token substitutions, or exact strings.
566569
- *Glob* style examples:
570+
567571
- `colors/*`: All keys under the "colors/" prefix
568572
- `number[0-9]`: Any key from "number0" to "number9"
569-
- `char?`: Any key with prefix "char" and a single digit suffix, like "charA"
570-
- `*`: Full access to all keys.
573+
- `char?`: Any key with the prefix "char" and a single digit suffix, like "charA"
574+
- `*`: Full access to all keys
575+
571576
- State store keys also support token substitution when key type is `pattern` and curly braces are reserved for this purpose. Token substitution examples:
577+
572578
- `clients/{principal.clientId}/*`
573579
- `usernames/{principal.username}/*`
574580
- `rooms/{principal.attributes.room}/*`
575581

576-
Here's an example of how you might author your state store resources:
582+
Here's an example of how you might author your state store resources.
577583

578584
# [Portal](#tab/portal)
579585

580-
In the Broker authorization rules for your authorization policy, add a similar configuration:
586+
In the broker authorization rules for your authorization policy, add a similar configuration:
581587

582588
```json
583589
[
@@ -727,7 +733,7 @@ resource brokerAuthorization 'Microsoft.IoTOperations/instances/brokers/authoriz
727733
}
728734
```
729735

730-
Deploy the Bicep file using Azure CLI.
736+
Deploy the Bicep file by using the Azure CLI:
731737

732738
```azurecli
733739
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -753,7 +759,7 @@ stateStoreResources:
753759

754760
## Update authorization
755761

756-
Broker authorization resources can be updated at runtime without restart. All clients connected at the time of the update of policy are disconnected. Changing the policy type is also supported.
762+
You can update broker authorization resources at runtime without restart. All clients connected at the time of the update of policy are disconnected. Changing the policy type is also supported.
757763

758764
```bash
759765
kubectl edit brokerauthorization my-authz-policies
@@ -763,10 +769,10 @@ kubectl edit brokerauthorization my-authz-policies
763769

764770
# [Portal](#tab/portal)
765771

766-
1. In the Azure portal, navigate to your IoT Operations instance.
772+
1. In the Azure portal, go to your IoT Operations instance.
767773
1. Under **Components**, select **MQTT Broker**.
768774
1. Select the broker listener you want to edit from the list.
769-
1. On the port you want to disable authorization, select **None** in the authorization dropdown.
775+
1. On the port where you want to disable authorization, select **None** in the authorization dropdown.
770776

771777
# [Bicep](#tab/bicep)
772778

@@ -780,10 +786,10 @@ To disable authorization, omit `authorizationRef` in the `ports` setting of your
780786

781787
## Unauthorized publish in MQTT 3.1.1
782788

783-
With MQTT 3.1.1, when a publish is denied, the client receives the PUBACK with no error because the protocol version doesn't support returning error code. MQTTv5 return PUBACK with reason code 135 (Not authorized) when publish is denied.
789+
With MQTT 3.1.1, when publish is denied, the client receives PUBACK with no error because the protocol version doesn't support returning error code. MQTTv5 returns PUBACK with reason code 135 (Not authorized) when publish is denied.
784790

785791
## Related content
786792

787-
- About [BrokerListener resource](howto-configure-brokerlistener.md)
793+
- [BrokerListener resource](howto-configure-brokerlistener.md)
788794
- [Configure authentication for a BrokerListener](./howto-configure-authentication.md)
789795
- [Tutorial: TLS, X.509 client authentication, and attribute-based access control (ABAC) authorization](./tutorial-tls-x509.md)

0 commit comments

Comments
 (0)