Skip to content

Commit ee02b32

Browse files
authored
Merge pull request #299108 from spelluru/egridprebuild0430
Event Grid - Pre Build updates
2 parents 821c08d + e820d0b commit ee02b32

10 files changed

+157
-80
lines changed

articles/event-grid/authenticate-with-namespaces-using-json-web-tokens.md

Lines changed: 108 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,33 @@ title: Authenticate with namespaces using JSON Web Tokens
33
description: This article shows you how to authenticate with Azure Event Grid namespace using JSON Web Tokens.
44
ms.topic: how-to
55
ms.custom: build-2024, devx-track-azurecli
6-
ms.date: 01/27/2025
6+
ms.date: 04/30/2025
77
author: Connected-Seth
88
ms.author: seshanmugam
99
---
1010

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.
1313

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.
1515

1616
## Prerequisites
1717

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:
1919

2020
- 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).
2322

2423
## High-level steps
2524

26-
To use custom JWT authentication for namespaces, follow these steps:
25+
To use OAuth 2.0 JWT authentication for namespaces, follow these steps:
2726

28-
1. Create a namespace and configure its subresources.
27+
1. Create a namespace and configure its subresources.
2928
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.
3433

3534
## Create a namespace and configure its subresources
3635
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
4443

4544
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).
4645

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
4851

4952
1. Use the following command to create an Azure Key Vault account:
5053

@@ -60,7 +63,7 @@ For information configuring system and user-assigned identities using the Azure
6063
> 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).
6164
6265
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
6467
You need to provide access to the namespace to access your Azure Key Vault account using the following steps:
6568
6669
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
8184
8285
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).
8386
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.
8687
87-
### Use Azure portal
88+
### Use Azure portal to configure authentication
8889
8990
1. Navigate to your Event Grid namespace in the [Azure portal](https://portal.azure.com).
9091
1. On the **Event Grid Namespace** page, select **Configuration** on the left menu.
9192
1. In the **Custom JWT authentication** section, specify values for the following properties:
9293
1. Select **Enable custom JWT authentication**.
9394
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**.
9596
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":::
9798
1. In the new page, specify values for the following properties.
9899
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.
99100
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 \
130131
}'
131132
132133
```
133-
## JSON Web Token format
134+
### JSON Web Token format
134135
JSON Web Tokens are divided into the JWT Header and JWT payload sections.
135136

136137
### JWT Header
@@ -184,6 +185,92 @@ Event Grid maps all claims to client attributes if they have one of the followin
184185
}
185186
```
186187

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.
198+
1. Select  issuer certificate option – **Direct Upload**.
199+
200+
:::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.
212+
213+
```azurecli
214+
az eventgrid namespace update \
215+
--resource-group <resource-group-name> \
216+
--name <namespace-name> \
217+
--api-version 2024-12-15-preview \
218+
--set customJwtAuthenticationSettings='{
219+
"tokenIssuer": "issuer-name",
220+
"encodedIssuerCertificates": [
221+
{
222+
"kid": "key1",
223+
"encodedCertificate": "-----BEGIN CERTIFICATE-----\n<certificate-in-PEM-format>\n-----END CERTIFICATE-----"
224+
}
225+
]
226+
}
227+
```
228+
229+
- 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.
244+
245+
246+
```json
247+
{
248+
  "typ": "JWT",
249+
  "alg": "RS256",
250+
  "kid": "keyId1"
251+
}.{
252+
  "iss": "some-issuer",
253+
  "sub": "device1",
254+
  "aud": "event-grid-namespace.ts.eventgrid.azure.net",
255+
  "exp": 1770426501,
256+
  "nbf": 1738886901,
257+
  "bool_attr": true,
258+
  "num_attr_pos": 1,
259+
  "num_attr_neg": -1,
260+
  "num_attr_to_big": 9223372036854775807,
261+
  "num_attr_float": 1.23,
262+
  "str_attr": "str_value",
263+
  "str_list_attr": [
264+
    "str_value_1",
265+
    "str_value_2"
266+
  ],
267+
  "obj_attr": {
268+
      "key": "value"
269+
  }
270+
}
271+
```
272+
273+
187274
## Related content
188275
- [MQTT client authentication](mqtt-client-authentication.md)
189276
- [Authenticate client using custom JWT](mqtt-client-custom-jwt.md)
107 KB
Loading
105 KB
Loading
84.9 KB
Loading

articles/event-grid/mqtt-client-authentication.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@ Azure Event Grid's MQTT broker supports the following authentication modes.
1515

1616
- Certificate-based authentication
1717
- Microsoft Entra ID authentication
18-
- Custom JWT authentication
18+
- OAuth 2.0 (JSON Web Token) authentication
1919

2020
## Certificate-based authentication
2121
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).
2222

2323
## Microsoft Entra ID authentication
2424
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).
2525

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+
2830

2931
## Related content
3032
- Learn how to [authenticate clients using certificate chain](mqtt-certificate-chain-client-authentication.md)
3133
- 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)
3335
- See [Transport layer security with MQTT broker](mqtt-transport-layer-security-flow.md)

articles/event-grid/mqtt-client-custom-jwt.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
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
44
ms.topic: conceptual
55
ms.custom: build-2024
6-
ms.date: 01/27/2025
6+
ms.date: 04/30/2025
77
author: Connected-Seth
88
ms.author: seshanmugam
99
ms.subservice: mqtt
1010
---
1111

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
1313

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.
1515

1616
> [!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.
1818
1919
## 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)
2121

2222
<a name='authentication-using-azure-ad-jwt'></a>
2323

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.
2626

2727
> [!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.
2929
3030
In the CONNECT packet, you can provide the required values in the following fields:
3131

@@ -45,10 +45,10 @@ In the AUTH packet, you can provide the required values in the following fields:
4545
Authenticate Reason Code with value 25 signifies reauthentication.
4646

4747
> [!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/`.
4949
5050
## 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.
5252

5353
## Next steps
5454
- See [Publish and subscribe to MQTT message using Event Grid](mqtt-publish-and-subscribe-portal.md)

0 commit comments

Comments
 (0)