Skip to content

Commit ca98cd3

Browse files
Merge pull request #246131 from kgremban/jul24-authauth
New auth/auth concept content
2 parents 26881ae + fa5872a commit ca98cd3

8 files changed

+367
-515
lines changed

articles/iot-hub/.openpublishing.redirection.iot-hub.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,36 @@
13451345
"redirect_url": "/azure/iot/iot-mqtt-connect-to-iot-hub",
13461346
"redirect_document_id": true
13471347
},
1348+
{
1349+
"source_path_from_root": "/articles/iot-hub/iot-hub-x509-certificate-concepts.md",
1350+
"redirect_url": "/azure/iot-hub/authenticate-authorize-x509",
1351+
"redirect_document_id": true
1352+
},
1353+
{
1354+
"source_path_from_root": "/articles/iot-hub/iot-hub-x509ca-overview.md",
1355+
"redirect_url": "/azure/iot-hub/authenticate-authorize-x509",
1356+
"redirect_document_id": false
1357+
},
1358+
{
1359+
"source_path_from_root": "/articles/iot-hub/iot-hub-x509ca-concept.md",
1360+
"redirect_url": "/azure/iot-hub/authenticate-authorize-x509",
1361+
"redirect_document_id": false
1362+
},
1363+
{
1364+
"source_path_from_root": "/articles/iot-hub/iot-hub-dev-guide-azure-ad-rbac.md",
1365+
"redirect_url": "/azure/iot-hub/authenticate-authorize-azure-ad",
1366+
"redirect_document_id": true
1367+
},
1368+
{
1369+
"source_path_from_root": "/articles/iot-hub/iot-hub-dev-guide-sas.md",
1370+
"redirect_url": "/azure/iot-hub/authenticate-authorize-sas",
1371+
"redirect_document_id": true
1372+
},
1373+
{
1374+
"source_path_from_root": "/articles/iot-hub/iot-hub-devguide-security.md",
1375+
"redirect_url": "/azure/iot-hub/authenticate-authorize-azure-ad",
1376+
"redirect_document_id": false
1377+
},
13481378
{
13491379
"source_path_from_root": "/articles/iot-hub/iot-hub-vscode-iot-toolkit-cloud-device-messaging.md",
13501380
"redirect_url": "/azure/iot-hub/reference-iot-hub-extension",

articles/iot-hub/TOC.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,17 @@
161161
- name: High availability and disaster recovery
162162
displayName: HA, DR, availability zone, failover, failback
163163
href: iot-hub-ha-dr.md
164-
- name: Control access to IoT Hub
164+
- name: Authentication and authorization
165165
items:
166-
- name: Overview
167-
displayName: access control, permissions, Azure Active Directory, Azure AD, identity registry
168-
href: iot-hub-devguide-security.md
169-
- name: Control access with Azure AD
170-
displayName: Active Directory, permissions, security principal, RBAC
171-
href: iot-hub-dev-guide-azure-ad-rbac.md
172-
- name: Control access with SAS
173-
displayName: Shared Access Signatures, permissions, MQTT, AMQP, HTTPS, SASL PLAIN
174-
href: iot-hub-dev-guide-sas.md
166+
- name: Azure Active Directory
167+
displayName: authenticate, authentication, auth, authn, authz
168+
href: authenticate-authorize-azure-ad.md
169+
- name: Shared access signatures
170+
displayName: authenticate, authentication, auth, authn, authz
171+
href: authenticate-authorize-sas.md
172+
- name: X.509 certificates
173+
displayName: authenticate, authentication, auth, authn, authz
174+
href: authenticate-authorize-x509.md
175175
- name: IoT Hub SDKs
176176
items:
177177
- name: SDK overview
@@ -194,16 +194,6 @@
194194
- name: TLS support
195195
displayName: security, Transport Layer Security
196196
href: iot-hub-tls-support.md
197-
- name: Secure using X.509 CA certificates
198-
items:
199-
- name: X.509 certificate concepts
200-
displayName: Public Key Cryptography, X.509 certificates, public key infrastructure (PKI), certificates, Certification Authorities, encryption, ciphertext
201-
href: iot-hub-x509-certificate-concepts.md
202-
- name: X.509 CA certificate security concepts
203-
displayName: Device Provisioning Service, DPS, Hardware Secure Modules, HSM, self-signed certificate, Public Key Infrastructure, PKI
204-
href: iot-hub-x509ca-concept.md
205-
- name: X.509 CA certificates for IoT Hub
206-
href: iot-hub-x509ca-overview.md
207197
- name: Virtual networks support
208198
displayName: Security, Private Link, network isolation, private endpoint
209199
href: virtual-network-support.md

articles/iot-hub/iot-hub-dev-guide-azure-ad-rbac.md renamed to articles/iot-hub/authenticate-authorize-azure-ad.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
---
2-
title: Control access to IoT Hub by using Azure Active Directory
3-
description: This article describes how to control access to IoT Hub for back-end apps by using Azure AD and Azure RBAC.
2+
title: Control access with Azure Active Directory
3+
titleSuffix: Azure IoT Hub
4+
description: Understand how Azure IoT Hub uses Azure Active Directory to authenticate identities and authorize access to IoT hubs and devices.
45
author: kgremban
5-
6-
ms.author: kgremban
76
ms.service: iot-hub
8-
ms.topic: concept-article
9-
ms.date: 01/18/2023
10-
ms.custom: ['Role: Cloud Development', devx-track-azurecli]
7+
services: iot-hub
8+
ms.author: kgremban
9+
ms.topic: conceptual
10+
ms.date: 09/01/2023
11+
ms.custom: ['Role: Cloud Development', 'Role: IoT Device', 'Role: System Architecture']
1112
---
1213

1314
# Control access to IoT Hub by using Azure Active Directory
1415

15-
You can use Azure Active Directory (Azure AD) to authenticate requests to Azure IoT Hub service APIs, like create device identity and invoke direct method. You can also use Azure role-based access control (Azure RBAC) to authorize those same service APIs. By using these technologies together, you can grant permissions to access IoT Hub service APIs to an Azure AD security principal. This security principal could be a user, group, or application service principal.
16+
You can use Azure Active Directory (Azure AD) to authenticate requests to Azure IoT Hub service APIs, like **create device identity** and **invoke direct method**. You can also use Azure role-based access control (Azure RBAC) to authorize those same service APIs. By using these technologies together, you can grant permissions to access IoT Hub service APIs to an Azure AD security principal. This security principal could be a user, group, or application service principal.
1617

17-
Authenticating access by using Azure AD and controlling permissions by using Azure RBAC provides improved security and ease of use over [security tokens](iot-hub-dev-guide-sas.md). To minimize potential security issues inherent in security tokens, we recommend that you [use Azure AD with your IoT hub whenever possible](#azure-ad-access-and-shared-access-policies).
18+
Authenticating access by using Azure AD and controlling permissions by using Azure RBAC provides improved security and ease of use over security tokens. To minimize potential security issues inherent in security tokens, we recommend that you [enforce Azure AD authentication whenever possible](#enforce-azure-ad-authentication).
1819

1920
> [!NOTE]
20-
> Authentication with Azure AD isn't supported for the IoT Hub *device APIs* (like device-to-cloud messages and update reported properties). Use [symmetric keys](iot-hub-dev-guide-sas.md#use-a-symmetric-key-in-the-identity-registry) or [X.509](iot-hub-x509ca-overview.md) to authenticate devices to IoT Hub.
21+
> Authentication with Azure AD isn't supported for the IoT Hub *device APIs* (like device-to-cloud messages and update reported properties). Use [symmetric keys](authenticate-authorize-sas.md) or [X.509](authenticate-authorize-x509.md) to authenticate devices to IoT Hub.
2122
2223
## Authentication and authorization
2324

25+
*Authentication* is the process of proving that you are who you say you are. Authentication verifies the identity of a user or device to IoT Hub. It's sometimes shortened to *AuthN*. *Authorization* is the process of confirming permissions for an authenticated user or device on IoT Hub. It specifies what resources and commands you're allowed to access, and what you can do with those resources and commands. Authorization is sometimes shortened to *AuthZ*.
26+
2427
When an Azure AD security principal requests access to an IoT Hub service API, the principal's identity is first *authenticated*. For authentication, the request needs to contain an OAuth 2.0 access token at runtime. The resource name for requesting the token is `https://iothubs.azure.net`. If the application runs in an Azure resource like an Azure VM, Azure Functions app, or Azure App Service app, it can be represented as a [managed identity](../active-directory/managed-identities-azure-resources/how-managed-identities-work-vm.md).
2528

2629
After the Azure AD principal is authenticated, the next step is *authorization*. In this step, IoT Hub uses the Azure AD role assignment service to determine what permissions the principal has. If the principal's permissions match the requested resource or API, IoT Hub authorizes the request. So this step requires one or more Azure roles to be assigned to the security principal. IoT Hub provides some built-in roles that have common groups of permissions.
@@ -91,36 +94,39 @@ The following table describes the permissions available for IoT Hub service API
9194
> [!NOTE]
9295
> To get data from IoT Hub by using Azure AD, [set up routing to a separate event hub](iot-hub-devguide-messages-d2c.md#event-hubs-as-a-routing-endpoint). To access the [the built-in Event Hubs compatible endpoint](iot-hub-devguide-messages-read-builtin.md), use the connection string (shared access key) method as before.
9396
94-
## Azure AD access and shared access policies
97+
## Enforce Azure AD authentication
9598

96-
By default, IoT Hub supports service API access through both Azure AD and [shared access policies and security tokens](iot-hub-dev-guide-sas.md). To minimize potential security vulnerabilities inherent in security tokens, disable access with shared access policies.
99+
By default, IoT Hub supports service API access through both Azure AD and [shared access policies and security tokens](authenticate-authorize-sas.md). To minimize potential security vulnerabilities inherent in security tokens, you can disable access with shared access policies.
100+
101+
> [!WARNING]
102+
> By denying connections using shared access policies, all users and services that connect using this method lose access immediately. Notably, since Device Provisioning Service (DPS) only supports linking IoT hubs using shared access policies, all device provisioning flows will fail with "unauthorized" error. Proceed carefully and plan to replace access with Azure AD role based access. **Do not proceed if you use DPS**.
97103
98104
1. Ensure that your service clients and users have [sufficient access](#manage-access-to-iot-hub-by-using-azure-rbac-role-assignment) to your IoT hub. Follow the [principle of least privilege](../security/fundamentals/identity-management-best-practices.md).
99105
1. In the [Azure portal](https://portal.azure.com), go to your IoT hub.
100106
1. On the left pane, select **Shared access policies**.
101107
1. Under **Connect using shared access policies**, select **Deny**, and review the warning.
102108
:::image type="content" source="media/iot-hub-dev-guide-azure-ad-rbac/disable-local-auth.png" alt-text="Screenshot that shows how to turn off IoT Hub shared access policies." border="true":::
103109

104-
> [!WARNING]
105-
> By denying connections using shared access policies, all users and services that connect using this method lose access immediately. Notably, since Device Provisioning Service (DPS) only supports linking IoT hubs using shared access policies, all device provisioning flows will fail with "unauthorized" error. Proceed carefully and plan to replace access with Azure AD role based access. **Do not proceed if you use DPS**.
106-
107110
Your IoT Hub service APIs can now be accessed only through Azure AD and RBAC.
108111

109112
## Azure AD access from the Azure portal
110113

111-
When you try to access IoT Hub, the Azure portal first checks whether you've been assigned an Azure role with `Microsoft.Devices/iotHubs/listkeys/action`. If you have, the Azure portal uses the keys from shared access policies to access IoT Hub. If not, the Azure portal tries to access data by using your Azure AD account.
114+
You can provide access to IoT Hub from the Azure portal with either shared access policies or Azure AD permissions.
112115

113-
To access IoT Hub from the Azure portal by using your Azure AD account, you need permissions to access IoT Hub data resources (like devices and twins). You also need permissions to go to the IoT Hub resource in the Azure portal. The built-in roles provided by IoT Hub grant access to resources like devices and twin. But they don't grant access to the IoT Hub resource. So access to the portal also requires the assignment of an Azure Resource Manager role like [Reader](../role-based-access-control/built-in-roles.md#reader). The Reader role is a good choice because it's the most restricted role that lets you navigate the portal. It doesn't include the `Microsoft.Devices/iotHubs/listkeys/action` permission (which provides access to all IoT Hub data resources via shared access policies).
116+
When you try to access IoT Hub from the Azure portal, the Azure portal first checks whether you've been assigned an Azure role with `Microsoft.Devices/iotHubs/listkeys/action`. If you have, the Azure portal uses the keys from shared access policies to access IoT Hub. If not, the Azure portal tries to access data by using your Azure AD account.
117+
118+
To access IoT Hub from the Azure portal by using your Azure AD account, you need permissions to access IoT Hub data resources (like devices and twins). You also need permissions to go to the IoT Hub resource in the Azure portal. The built-in roles provided by IoT Hub grant access to resources like devices and twin but they don't grant access to the IoT Hub resource. So access to the portal also requires the assignment of an Azure Resource Manager role like [Reader](../role-based-access-control/built-in-roles.md#reader). The reader role is a good choice because it's the most restricted role that lets you navigate the portal. It doesn't include the `Microsoft.Devices/iotHubs/listkeys/action` permission (which provides access to all IoT Hub data resources via shared access policies).
114119

115120
To ensure an account doesn't have access outside of the assigned permissions, don't include the `Microsoft.Devices/iotHubs/listkeys/action` permission when you create a custom role. For example, to create a custom role that can read device identities but can't create or delete devices, create a custom role that:
121+
116122
- Has the `Microsoft.Devices/IotHubs/devices/read` data action.
117123
- Doesn't have the `Microsoft.Devices/IotHubs/devices/write` data action.
118124
- Doesn't have the `Microsoft.Devices/IotHubs/devices/delete` data action.
119125
- Doesn't have the `Microsoft.Devices/iotHubs/listkeys/action` action.
120126

121127
Then, make sure the account doesn't have any other roles that have the `Microsoft.Devices/iotHubs/listkeys/action` permission, like [Owner](../role-based-access-control/built-in-roles.md#owner) or [Contributor](../role-based-access-control/built-in-roles.md#contributor). To allow the account to have resource access and navigate the portal, assign [Reader](../role-based-access-control/built-in-roles.md#reader).
122128

123-
## Azure IoT extension for Azure CLI
129+
## Azure AD access from Azure CLI
124130

125131
Most commands against IoT Hub support Azure AD authentication. You can control the type of authentication used to run commands by using the `--auth-type` parameter, which accepts `key` or `login` values. The `key` value is the default.
126132

@@ -132,10 +138,12 @@ For more information, see the [Azure IoT extension for Azure CLI release page](h
132138

133139
## SDK samples
134140

135-
- [.NET Microsoft.Azure.Devices SDK sample](https://aka.ms/iothubaadcsharpsample)
141+
- [.NET SDK sample](https://github.com/Azure/azure-iot-sdk-csharp/blob/main/iothub/service/samples/how%20to%20guides/RoleBasedAuthenticationSample/Program.cs)
136142
- [Java SDK sample](https://github.com/Azure/azure-iot-service-sdk-java/tree/main/service/iot-service-samples/role-based-authorization-sample)
137143

138144
## Next steps
139145

140146
- For more information on the advantages of using Azure AD in your application, see [Integrating with Azure Active Directory](../active-directory/develop/how-to-integrate.md).
141147
- For more information on requesting access tokens from Azure AD for users and service principals, see [Authentication scenarios for Azure AD](../active-directory/develop/authentication-vs-authorization.md).
148+
149+
Use the Device Provisioning Service to [Provision multiple X.509 devices using enrollment groups](../iot-dps/tutorial-custom-hsm-enrollment-group-x509.md).

0 commit comments

Comments
 (0)