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
@@ -3,34 +3,33 @@ title: Authenticate with namespaces using JSON Web Tokens
3
3
description: This article shows you how to authenticate with Azure Event Grid namespace using JSON Web Tokens.
4
4
ms.topic: how-to
5
5
ms.custom: build-2024, devx-track-azurecli
6
-
ms.date: 01/27/2025
6
+
ms.date: 04/30/2025
7
7
author: Connected-Seth
8
8
ms.author: seshanmugam
9
9
---
10
10
11
-
# Authenticate with namespaces using JSON Web Tokens
12
-
This article shows how to authenticate with Azure Event Grid namespace using JSON Web Tokens.
11
+
# Use OAuth 2.0 JSON Web Tokens (JWT) to authenticate with namespaces
12
+
This article shows how to authenticate with Azure Event Grid namespace using OAuth 2.0 JSON Web Tokens.
13
13
14
-
Azure Event Grid's MQTT broker supports custom JWT authentication, which enables clients to connect and authenticate with an Event Grid namespace using JSON Web Tokens that are issued by any identity provider, aside from Microsoft Entra ID.
14
+
Azure Event Grid's MQTT broker supports OAuth 2.0 JWT authentication, which enables clients to connect and authenticate with an Event Grid namespace using JSON Web Tokens that are issued by any identity provider, aside from Microsoft Entra ID.
15
15
16
16
## Prerequisites
17
17
18
-
To use custom JWT authentication for namespaces, you need to have the following prerequisites:
18
+
To use OAuth 2.0 JWT authentication for namespaces, you need to have the following prerequisites:
19
19
20
20
- Identity provider that can issue JSON Web Tokens.
21
-
- CA certificate that includes your public keys used to validate the client tokens.
22
-
- Azure Key Vault account to host the CA certificate that includes your public keys.
21
+
- CA certificate that includes your public keys used to validate the client tokens(Key Vault) or PEM file of your public key certificates(direct upload).
23
22
24
23
## High-level steps
25
24
26
-
To use custom JWT authentication for namespaces, follow these steps:
25
+
To use OAuth 2.0 JWT authentication for namespaces, follow these steps:
27
26
28
-
1. Create a namespace and configure its subresources.
27
+
1. Create a namespace and configure its subresources.
29
28
1. Enable managed identity on your Event Grid namespace.
30
-
1.Create an Azure Key Vault account that hosts the CA certificate that includes your public keys.
31
-
1.Add role assignment in Azure Key Vault for the namespace’s managed identity.
32
-
1.Configure custom authentication settings on your Event Grid namespace
33
-
1. Your clients can connect to the Event Grid namespace using the tokens provided by your identity provider.
29
+
1.Configure OAuth 2.0 authentication settings on your Event Grid namespace by following these steps:
30
+
1.Create an Azure Key Vault account that hosts the CA certificate that includes your public keys and add role assignment in Key Vault for the namespace’s managed identity.
31
+
1.Upload the PEM file of your public key certificates to namespace.
32
+
1. Your clients can connect to the Event Grid namespace using the tokens provided by your identity provider.
34
33
35
34
## Create a namespace and configure its subresources
36
35
Follow instructions from [Quickstart: Publish and subscribe to MQTT messages on Event Grid Namespace with Azure portal](mqtt-publish-and-subscribe-portal.md) to create a namespace and configure its subresources. Skip the certificate and client creation steps as the client identities come from the provided token. Client attributes are based on the custom claims in the client token. The client attributes are used in the client group query, topic template variables, and routing enrichment configuration.
@@ -44,7 +43,11 @@ az eventgrid namespace update --resource-group <resource group name> --name <nam
44
43
45
44
For information configuring system and user-assigned identities using the Azure portal, see [Enable managed identity for an Event Grid namespace](event-grid-namespace-managed-identity.md).
46
45
47
-
## Create an Azure Key Vault account and upload your server certificate
46
+
47
+
## Configure OAuth 2.0 JWT authentication settings on your Event Grid namespace -Key Vault
48
+
First, create an Azure Key Vault account, upload your server certificate, and assign the namespace's managed identity an appropriate role on the key vault. Then, you configure custom authentication settings on your Event Grid namespace using Azure portal and Azure CLI. You need to create the namespace first then update it using the following steps.
49
+
50
+
### Create an Azure Key Vault account and upload your server certificate
48
51
49
52
1. Use the following command to create an Azure Key Vault account:
50
53
@@ -60,7 +63,7 @@ For information configuring system and user-assigned identities using the Azure
60
63
> Your certificate must include the domain name in the Subject Alternative name for DNS. For more information, see [Tutorial: Import a certificate in Azure Key Vault](/azure/key-vault/certificates/tutorial-import-certificate).
61
64
62
65
63
-
## Add role assignment in Azure Key Vault for the namespace’s managed identity
66
+
### Add role assignment in Azure Key Vault for the namespace’s managed identity
64
67
You need to provide access to the namespace to access your Azure Key Vault account using the following steps:
65
68
66
69
1. Get Event Grid namespace system managed identity principal ID using the following command
@@ -81,19 +84,17 @@ You need to provide access to the namespace to access your Azure Key Vault accou
81
84
82
85
For more information about Key Vault access and the portal experience, see [Provide access to Key Vault keys, certificates, and secrets with an Azure role-based access control](/azure/key-vault/general/rbac-guide).
83
86
84
-
## Configure custom authentication settings on your Event Grid namespace
85
-
In this step, you configure custom authentication settings on your Event Grid namespace using Azure portal and Azure CLI. You need to create the namespace first then update it using the following steps.
86
87
87
-
### Use Azure portal
88
+
### Use Azure portal to configure authentication
88
89
89
90
1. Navigate to your Event Grid namespace in the [Azure portal](https://portal.azure.com).
90
91
1. On the **Event Grid Namespace** page, select **Configuration** on the left menu.
91
92
1. In the **Custom JWT authentication** section, specify values for the following properties:
92
93
1. Select **Enable custom JWT authentication**.
93
94
1. **Token Issuer**: Enter the value of the issuer claims of the JWTs, presented by the MQTT clients.
94
-
1. Select **Add issuer certificate**
95
+
1. For **Issuer certificate**, select **From Azure Key Vault**.
95
96
96
-
:::image type="content" source="./media/authenticate-with-namespaces-using-json-web-tokens/configuration-custom-authentication.png" alt-text="Screenshot that shows the Custom JWT authentication section of the Configuration page for an Event Grid namespace." lightbox="./media/authenticate-with-namespaces-using-json-web-tokens/configuration-custom-authentication.png":::
97
+
:::image type="content" source="./media/authenticate-with-namespaces-using-json-web-tokens/select-azure-key-vault-option.png" alt-text="Screenshot that shows the selection of the Azure Key Vault option of the Configuration page for an Event Grid namespace." lightbox="./media/authenticate-with-namespaces-using-json-web-tokens/select-azure-key-vault-option.png":::
97
98
1. In the new page, specify values for the following properties.
98
99
1. **Certificate URL**: the Certificate Identifier of the issuer certificate in Azure Key Vault that you created. You can choose **Select a certificate using a key vault** instead to select the certificate and the key vault from your subscriptions.
99
100
1. **Identity**: the identity used to authenticate with the Key Vault to access the issuer certificate that was created.
@@ -130,7 +131,7 @@ az resource update \
130
131
}'
131
132
132
133
```
133
-
## JSON Web Token format
134
+
###JSON Web Token format
134
135
JSON Web Tokens are divided into the JWT Header and JWT payload sections.
135
136
136
137
### JWT Header
@@ -184,6 +185,92 @@ Event Grid maps all claims to client attributes if they have one of the followin
184
185
}
185
186
```
186
187
188
+
## Configure OAuth 2.0 JWT authentication settings on your Event Grid namespace - Direct upload
189
+
190
+
In this step, you configure custom JWT authentication settings on your Event Grid namespace using Azure portal and Azure CLI. You need to create the namespace first then update it using the following steps.
191
+
192
+
### Use Azure portal
193
+
1. Navigate to your Event Grid namespace in the Azure portal.
194
+
1. On the Event Grid Namespace page, select Configuration on the left menu.
195
+
1. In the Custom JWT authentication section, specify values for the following properties:
196
+
1. Select **Enable custom JWT authentication**.
197
+
1.**Token Issuer**: Enter the value of the issuer claims of the JWTs, presented by the MQTT clients.
:::image type="content" source="./media/authenticate-with-namespaces-using-json-web-tokens/direct-upload-option.png" alt-text="Screenshot that shows the selection of the Direct Upload option of the Configuration page for an Event Grid namespace." lightbox="./media/authenticate-with-namespaces-using-json-web-tokens/direct-upload-option.png":::
201
+
1. In the new page, specify values for the following properties.
202
+
1.**Certificate**: upload your server certificate in PEM Format.
203
+
1.**Kid**: A unique key identifier for the certificate.
204
+
1. Select **Add**.
205
+
206
+
:::image type="content" source="./media/authenticate-with-namespaces-using-json-web-tokens/upload-certificate.png" alt-text="Screenshot that shows the Upload issuer certificate page." lightbox="./media/authenticate-with-namespaces-using-json-web-tokens/upload-certificate.png":::
207
+
1. Back on the **Configuration** page, select **Apply**.
208
+
209
+
210
+
### Use Azure CLI
211
+
Use the following command to update your namespace with the OAuth 2.0 JWT authentication configuration.
- Replace `<resource-group-name>`, `<namespace-name>`, `<location>`, `<key-vault-name>`, `<certificate-name>`, and `<certificate-in-PEM-format>` with your actual values.
230
+
- The encodedCertificate value must include the full certificate in PEM format, including headers ( `"-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE----`).
231
+
- Ensure the public key certificate provided is valid and trusted by your identity provider.
232
+
- Regularly update the encodedIssuerCertificates if certificates are rotated or expired.
233
+
234
+
### JSON Web Token format
235
+
236
+
JWT payload
237
+
238
+
Event Grid requires the following claims: `iss`, `sub`, `aud`, `exp`, `nbf`.
239
+
240
+
*`kid` is optional. If it is present, then certificate with matching `kid` is used for validation.
241
+
* List of standard claims that aren't used as attributes - `iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`.
242
+
* All claims which have correct data type (number that fits int32, string, array of strings) are used as attributes. In the example `num_attr_pos`, `num_attr_neg`, `str_attr`, `str_list_attr` claims have correct data types and are used as attributes.
243
+
* In the example `bool_attr`, `num_attr_to_big`, `num_attr_float`, `obj_attr` claims have incorrect data types and aren't be used as attributes.
Copy file name to clipboardExpand all lines: articles/event-grid/mqtt-client-authentication.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,19 +15,21 @@ Azure Event Grid's MQTT broker supports the following authentication modes.
15
15
16
16
- Certificate-based authentication
17
17
- Microsoft Entra ID authentication
18
-
-Custom JWT authentication
18
+
-OAuth 2.0 (JSON Web Token) authentication
19
19
20
20
## Certificate-based authentication
21
21
You can use Certificate Authority (CA) signed certificates or self-signed certificates to authenticate clients. For more information, see [MQTT Client authentication using certificates](mqtt-client-certificate-authentication.md).
22
22
23
23
## Microsoft Entra ID authentication
24
24
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. For more information, see [Microsoft Entra JWT authentication and Azure RBAC authorization to publish or subscribe MQTT messages](mqtt-client-microsoft-entra-token-and-rbac.md).
25
25
26
-
## Custom JWT authentication
27
-
You can authenticate MQTT clients using JSON Web Tokens (JWT) issued by any third-party OpenID Connect (OIDC) identity provider. This authentication method provides a lightweight, secure, and flexible option for MQTT clients that aren't provisioned in Azure. For more information, see [authenticate client using custom JWT](mqtt-client-custom-jwt.md)
26
+
## OAuth 2.0 JWT authentication
27
+
You can authenticate MQTT clients using JSON Web Tokens (JWT) issued by any third-party OpenID Connect (OIDC) identity provider. This authentication method provides a lightweight, secure, and flexible option for MQTT clients that aren't provisioned in Azure. For more information, see [Authenticate client using OAuth 2.0 JWT](mqtt-client-custom-jwt.md).
28
+
29
+
28
30
29
31
## Related content
30
32
- Learn how to [authenticate clients using certificate chain](mqtt-certificate-chain-client-authentication.md)
31
33
- Learn how to [authenticate client using Microsoft Entra ID token](mqtt-client-azure-ad-token-and-rbac.md)
32
-
- Learn how to[authenticate client using custom JWT](mqtt-client-custom-jwt.md)
34
+
- Learn how to[authenticate client using OAuth 2.0 JWT](mqtt-client-custom-jwt.md)
33
35
- See [Transport layer security with MQTT broker](mqtt-transport-layer-security-flow.md)
Copy file name to clipboardExpand all lines: articles/event-grid/mqtt-client-custom-jwt.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,31 @@
1
1
---
2
-
title: Custom JWT authentication
3
-
description: Describes custom JWT authentication and authorization to publish or subscribe to MQTT messages
2
+
title: OAuth 2.0 JWT authentication
3
+
description: Describes OAuth 2.0 JWT authentication and authorization to publish or subscribe to MQTT messages
4
4
ms.topic: conceptual
5
5
ms.custom: build-2024
6
-
ms.date: 01/27/2025
6
+
ms.date: 04/30/2025
7
7
author: Connected-Seth
8
8
ms.author: seshanmugam
9
9
ms.subservice: mqtt
10
10
---
11
11
12
-
# Custom JWT authentication and authorization to publish or subscribe to MQTT messages
12
+
# OAuth 2.0 JSON Web Token (JWT) authentication and authorization to publish or subscribe to MQTT messages
13
13
14
-
You can authenticate MQTT clients with Custom JWT to connect to the Event Grid namespace. You can embed and validate custom claims in the JWT to authorize publish or subscribe permissions to your Event Grid topic spaces.
14
+
You can authenticate MQTT clients with OAuth 2.0 JWT to connect to the Event Grid namespace. You can embed and validate custom claims in the JWT to authorize publish or subscribe permissions to your Event Grid topic spaces.
15
15
16
16
> [!IMPORTANT]
17
-
> -This feature is supported only when using the MQTT v5 protocol version.
17
+
> This feature is supported only when using the MQTT v5 protocol version.
18
18
19
19
## Prerequisites
20
-
- 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)
20
+
- 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)
21
21
22
22
<aname='authentication-using-azure-ad-jwt'></a>
23
23
24
-
## Authentication using Custom JWT
25
-
You can use the MQTT v5 CONNECT packet to provide the Custom JWT to authenticate your client and the MQTT v5 AUTH packet to refresh the token.
24
+
## Authentication using OAuth 2.0 JWT
25
+
You can use the MQTT v5 CONNECT packet to provide the OAuth 2.0 JWT to authenticate your client and the MQTT v5 AUTH packet to refresh the token.
26
26
27
27
> [!IMPORTANT]
28
-
> -If you don't set the CONNECT packet's authentication method to CUSTOM-JWT, you receive an 'invalid issuer' error—even if all other configurations are correct.
28
+
> If you don't set the CONNECT packet's authentication method to CUSTOM-JWT, you receive an 'invalid issuer' error—even if all other configurations are correct.
29
29
30
30
In the CONNECT packet, you can provide the required values in the following fields:
31
31
@@ -45,10 +45,10 @@ In the AUTH packet, you can provide the required values in the following fields:
45
45
Authenticate Reason Code with value 25 signifies reauthentication.
46
46
47
47
> [!NOTE]
48
-
> -Audience: 'aud' claim must be set to "https://eventgrid.azure.net/".
48
+
> Audience: `aud` claim must be set to `https://[namespace].ts.eventgrid.azure.net/`.
49
49
50
50
## Access permissions
51
-
A client using Custom JWT authentication can use client attributes and permissions to limit access to specific topics.
51
+
A client using OAuth 2.0 JWT authentication can use client attributes and permissions to limit access to specific topics.
52
52
53
53
## Next steps
54
54
- See [Publish and subscribe to MQTT message using Event Grid](mqtt-publish-and-subscribe-portal.md)
0 commit comments