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/event-grid/mqtt-client-azure-ad-token-and-rbac.md
+18-87Lines changed: 18 additions & 87 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,21 @@
2
2
title: Microsoft Entra JWT authentication and RBAC authorization for clients with Microsoft Entra identity
3
3
description: Describes JWT authentication and RBAC roles to authorize clients with Microsoft Entra identity to publish or subscribe MQTT messages
4
4
ms.topic: conceptual
5
-
ms.date: 8/11/2023
5
+
ms.date: 10/24/2023
6
6
author: veyaddan
7
7
ms.author: veyaddan
8
8
---
9
9
10
10
# Microsoft Entra JWT authentication and Azure RBAC authorization to publish or subscribe MQTT messages
11
+
11
12
You can authenticate MQTT clients with Microsoft Entra JWT to connect to Event Grid namespace. You can use Azure role-based access control (Azure RBAC) to enable MQTT clients, with Microsoft Entra identity, to publish or subscribe access to specific topic spaces.
12
13
14
+
13
15
> [!IMPORTANT]
14
-
> This feature is supported only when using MQTT v5
16
+
> This feature is supported only when using MQTT v5 protocol version
15
17
16
18
## Prerequisites
17
19
- You need an Event Grid namespace with MQTT enabled. Learn about [creating Event Grid namespace](/azure/event-grid/create-view-manage-namespaces#create-a-namespace)
18
-
- Review the process to [create a custom role](/azure/role-based-access-control/custom-roles-portal)
19
-
20
20
21
21
<aname='authentication-using-azure-ad-jwt'></a>
22
22
@@ -44,100 +44,30 @@ Authenticate Reason Code with value 25 signifies reauthentication.
44
44
> Audience: “aud” claim must be set to "https://eventgrid.azure.net/".
45
45
46
46
## Authorization to grant access permissions
47
-
A client using Microsoft Entra ID based JWT authentication needs to be authorized to communicate with the Event Grid namespace. You can create custom roles to enable the client to communicate with Event Grid instances in your resource group, and then assign the roles to the client. You can use following two data actions to provide publish or subscribe permissions, to clients with Microsoft Entra identities, on specific topic spaces.
47
+
A client using Microsoft Entra ID based JWT authentication needs to be authorized to communicate with the Event Grid namespace. You can assign the following two built-in roles to provide either publish or subscribe permissions, to clients with Microsoft Entra identities.
48
48
49
-
**Topic spaces publish**data action
50
-
Microsoft.EventGrid/topicSpaces/publish/action
49
+
- Use **EventGrid TopicSpaces Publisher**role to provide MQTT message publisher access
50
+
- Use **EventGrid TopicSpaces Subscriber** role to provide MQTT message subscriber access
51
51
52
-
**Topic spaces subscribe** data action
53
-
Microsoft.EventGrid/topicSpaces/subscribe/action
52
+
You can use these roles to provide permissions at subscription, resource group, Event Grid namespace or Event Grid topicspace scope.
53
+
54
+
## Assigning the publisher role to your Microsoft Entra identity at topicspace scope
54
55
55
-
> [!NOTE]
56
-
> Currently, we recommend using custom roles with the actions provided.
57
-
58
-
### Custom roles
59
-
60
-
You can create custom roles using the publish and subscribe actions.
61
-
62
-
The following are sample role definitions that allow you to publish and subscribe to MQTT messages. These custom roles give permissions at topic space scope. You can also create roles to provide permissions at subscription, resource group scope.
1. Navigate to topic spaces page in your Event Grid namespace
110
-
1. Select the topic space for which the custom RBAC role needs to be created
111
-
1. Navigate to the Access control (IAM) page within the topic space
112
-
1. In the Roles tab, right select any of the roles to clone a new custom role. Provide the custom role name.
113
-
1. Switch the Baseline permissions to **Start from scratch**
114
-
1. On the Permissions tab, select **Add permissions**
115
-
1. In the selection page, find and select Microsoft Event Grid
116
-
:::image type="content" source="./media/mqtt-client-azure-ad-token-and-rbac/event-grid-custom-role-permissions.png" lightbox="./media/mqtt-client-azure-ad-token-and-rbac/event-grid-custom-role-permissions.png" alt-text="Screenshot showing the Microsoft Event Grid option to find the permissions.":::
117
-
1. Navigate to Data Actions
118
-
1. Select **Topic spaces publish** data action and select **Add**
119
-
:::image type="content" source="./media/mqtt-client-azure-ad-token-and-rbac/event-grid-custom-role-permissions-data-actions.png" lightbox="./media/mqtt-client-azure-ad-token-and-rbac/event-grid-custom-role-permissions-data-actions.png" alt-text="Screenshot showing the data action selection.":::
120
-
1. Select Next to see the topic space in the Assignable scopes tab. You can add other assignable scopes if needed.
121
-
1. Select **Create** in Review + create tab to create the custom role.
122
-
1. Once the custom role is created, you can assign the role to an identity to provide the publish permission on the topic space. You can learn how to assign roles [here](/azure/role-based-access-control/role-assignments-portal).
## Assign the custom role to your Microsoft Entra identity
127
56
1. In the Azure portal, navigate to your Event Grid namespace
128
-
1. Navigate to the topic space to which you want to authorize access.
129
-
1. Go to the Access control (IAM) page of the topic space
57
+
1. Navigate to the topicspace to which you want to authorize access.
58
+
1. Go to the Access control (IAM) page of the topicspace
130
59
1. Select the **Role assignments** tab to view the role assignments at this scope.
131
60
1. Select **+ Add** and Add role assignment.
132
-
1. On the Role tab, select the role that you created in the previous step.
133
-
1. On the Members tab, select User, group, or service principal to assign the selected role to one or more service principals (applications).
61
+
1. On the Role tab, select the "EventGrid TopicSpaces Publisher" role.
62
+
1. On the Members tab, for **Assign access to**, select User, group, or service principal option to assign the selected role to one or more service principals (applications).
134
63
- Users and groups work when user/group belong to fewer than 200 groups.
135
-
1. Select **Select members**.
64
+
1. Select **+ Select members**.
136
65
1. Find and select the users, groups, or service principals.
66
+
1. Select **Next**
137
67
1. Select **Review + assign** on the Review + assign tab.
138
68
139
69
> [!NOTE]
140
-
> You can follow similar steps to create and assign a custom Event Grid MQTT subscriber permission to a topic space.
70
+
> You can follow similar steps to assign the built-in EventGrid TopicSpaces Subscriber role at topicspace scope.
141
71
142
72
## Next steps
143
73
- See [Publish and subscribe to MQTT message using Event Grid](mqtt-publish-and-subscribe-portal.md)
@@ -146,3 +76,4 @@ The following are sample role definitions that allow you to publish and subscrib
146
76
- To learn more about Azure Identity client library, you can refer to [using Azure Identity client library](/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-the-azure-identity-client-library)
147
77
- To learn more about implementing an interface for credentials that can provide a token, you can refer to [TokenCredential Interface](/java/api/com.azure.core.credential.tokencredential)
148
78
- To learn more about how to authenticate using Azure Identity, you can refer to [examples](https://github.com/Azure/azure-sdk-for-java/wiki/Azure-Identity-Examples)
79
+
- If you prefer to use custom roles, you can review the process to [create a custom role](/azure/role-based-access-control/custom-roles-portal)
0 commit comments