You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-operations/manage-mqtt-broker/howto-configure-authorization.md
+51-45Lines changed: 51 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Authorization policies determine what actions the clients can perform on the bro
21
21
22
22
## Link BrokerAuthorization to BrokerListener
23
23
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:
25
25
26
26
> [!IMPORTANT]
27
27
> 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
30
30
31
31
## Authorization rules
32
32
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.
34
34
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.
36
36
37
37
# [Portal](#tab/portal)
38
38
39
-
1. In the Azure portal, navigate to your IoT Operations instance.
39
+
1. In the Azure portal, go to your IoT Operations instance.
40
40
1. Under **Components**, select **MQTT Broker**.
41
41
1. Select the **Authorization** tab.
42
42
1. Choose an existing authentication policy or create a new one by selecting **Create authorization policy**.
43
43
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.":::
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
155
155
156
156
---
157
157
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:
159
159
160
160
- Connect to the broker.
161
161
- Publish messages to telemetry topics scoped with their client IDs and organization. For example:
162
162
- `temperature-sensor`can publish to `/telemetry/temperature-sensor` and `/telemetry/contoso`.
163
163
- `humidity-sensor`can publish to `/telemetry/humidity-sensor` and `/telemetry/contoso`.
164
164
- `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:
166
166
- `temperature-sensor`can subscribe to `/commands/contoso`.
167
167
- `some-other-username`can subscribe to `/commands/contoso`.
168
168
169
-
### Using username for authorization
169
+
### Use a username for authorization
170
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:
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:
172
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.
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.
176
176
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.
178
178
179
179
### Further limit access based on client ID
180
180
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:
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -315,37 +315,37 @@ spec:
315
315
316
316
---
317
317
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.
319
319
320
320
## Authorize clients that use X.509 authentication
321
321
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.
323
323
324
-
### Using attributes
324
+
### Use attributes
325
325
326
326
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).
327
327
328
328
### With client certificate subject common name as username
329
329
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.
331
331
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.
333
333
334
-
## Authorize clients that use Kubernetes Service Account Tokens
334
+
## Authorize clients that use Kubernetes service account tokens
335
335
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:
Attribute annotations must begin with `aio-broker-auth/` to distinguish them from other annotations.
343
343
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:
345
345
346
346
# [Portal](#tab/portal)
347
347
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:
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
493
493
494
494
### State store keys
495
495
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.
498
498
499
499
The `stateStoreResources` section format consists of access level, a pattern indicator, and the pattern.
500
500
@@ -551,33 +551,39 @@ stateStoreResources:
551
551
552
552
---
553
553
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`.
556
557
- Access level is required.
557
558
- Read access level implies the actions of `get` and `keynotify`.
558
559
- Write access level implies the actions of `set`, `del`, and `vdel`.
559
560
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.
564
568
565
-
The `keys` field specifies the keys to match. The keys can be specified as *Glob* style patterns, token substitutions, or exact strings.
566
569
- *Glob* style examples:
570
+
567
571
- `colors/*`: All keys under the "colors/" prefix
568
572
- `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
+
571
576
- State store keys also support token substitution when key type is `pattern` and curly braces are reserved for this purpose. Token substitution examples:
577
+
572
578
- `clients/{principal.clientId}/*`
573
579
- `usernames/{principal.username}/*`
574
580
- `rooms/{principal.attributes.room}/*`
575
581
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.
577
583
578
584
# [Portal](#tab/portal)
579
585
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:
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
@@ -753,7 +759,7 @@ stateStoreResources:
753
759
754
760
## Update authorization
755
761
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.
1. In the Azure portal, navigate to your IoT Operations instance.
772
+
1. In the Azure portal, go to your IoT Operations instance.
767
773
1. Under **Components**, select **MQTT Broker**.
768
774
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.
770
776
771
777
# [Bicep](#tab/bicep)
772
778
@@ -780,10 +786,10 @@ To disable authorization, omit `authorizationRef` in the `ports` setting of your
780
786
781
787
## Unauthorized publish in MQTT 3.1.1
782
788
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.
784
790
785
791
## Related content
786
792
787
-
- About [BrokerListener resource](howto-configure-brokerlistener.md)
0 commit comments