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
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.
17
17
18
-
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 [use Azure AD with your IoT hub whenever possible](#azure-ad-access-and-shared-access-policies).
19
19
20
20
> [!NOTE]
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](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.
22
22
23
23
## Authentication and authorization
24
24
25
-
*Authentication* is the process of proving that you are who you say you are. This is achieved by verifying of 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*.
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
26
27
27
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).
28
28
@@ -96,7 +96,7 @@ The following table describes the permissions available for IoT Hub service API
96
96
97
97
## Azure AD access and shared access policies
98
98
99
-
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, disable access with shared access policies.
100
100
101
101
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).
102
102
1. In the [Azure portal](https://portal.azure.com), go to your IoT hub.
Copy file name to clipboardExpand all lines: articles/iot-hub/authenticate-authorize-sas.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.date: 09/01/2023
10
10
ms.custom: ['Role: Cloud Development', 'Role: IoT Device', 'Role: System Architecture']
11
11
---
12
12
13
-
# Controll access to IoT Hub with shared access signatures
13
+
# Control access to IoT Hub with shared access signatures
14
14
15
15
IoT Hub uses shared access signature (SAS) tokens to authenticate devices and services to avoid sending keys on the wire. You use SAS tokens to grant time-bounded access to devices and services to specific functionality in IoT Hub. To get authorization to connect to IoT Hub, devices and services must send SAS tokens signed with either a shared access or symmetric key. Symmetric keys are stored with a device identity in the identity registry.
16
16
@@ -27,7 +27,7 @@ IoT Hub uses *permissions* to grant access to each IoT hub endpoint. Permissions
27
27
28
28
## Authentication and authorization
29
29
30
-
*Authentication* is the process of proving that you are who you say you are. This is achieved by verifying of 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*.
30
+
*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*.
31
31
32
32
This article describes authentication and authorization using **Shared access signatures**, which lets you group permissions and grant them to applications using access keys and signed security tokens. You can also use symmetric keys or shared access keys to authenticate a device with IoT Hub. SAS tokens provide authentication for each call made by the device to IoT Hub by associating the symmetric key to each call.
33
33
@@ -64,7 +64,7 @@ You can use the following permissions to control access to your IoT hub:
64
64
* The **RegistryRead** permission is used by back-end cloud services and grants the following access:
65
65
* Read access to the identity registry. For more information, see [Identity registry](iot-hub-devguide-identity-registry.md).
66
66
67
-
* The **RegistryReadWrite** permission is used by back-end cloud services and grants the follwoing access:
67
+
* The **RegistryReadWrite** permission is used by back-end cloud services and grants the following access:
68
68
* Read and write access to the identity registry. For more information, see [Identity registry](iot-hub-devguide-identity-registry.md).
69
69
70
70
### Per-device security credentials
@@ -75,9 +75,9 @@ When you register a device to use SAS token authentication, that device gets two
75
75
76
76
## Use SAS tokens from services
77
77
78
-
Services can generate SAS tokens by using a shared access policy which defines the appropriate permissions as explained previously in the [Access control and permissions](#access-control-and-permissions) section.
78
+
Services can generate SAS tokens by using a shared access policy that defines the appropriate permissions as explained previously in the [Access control and permissions](#access-control-and-permissions) section.
79
79
80
-
As an example, a service using the pre-created shared access policy called **registryRead** would create a token with the following parameters:
80
+
As an example, a service using the precreated shared access policy called **registryRead** would create a token with the following parameters:
* signing key: one of the keys of the `registryRead` policy,
@@ -100,7 +100,7 @@ The result, which grants access to read all device identities in the identity re
100
100
101
101
For more examples, see [Generate SAS tokens](#generate-sas-tokens).
102
102
103
-
For services, SAS tokens only grant permissions at the IoT Hub level. That is, a service authenticating with a token based on the **service** policy will be able to perform all the operations granted by the **ServiceConnect** permission. These operations include receiving device-to-cloud messages, sending cloud-to-device messages, and so on. If you want to grant more granular access to your services, for example, limiting a service to only sending cloud-to-device messages, you can use Azure Active Directory. To learn more, see [Authenticate with Azure AD](authenticate-azure-ad.md).
103
+
For services, SAS tokens only grant permissions at the IoT Hub level. That is, a service authenticating with a token based on the **service** policy will be able to perform all the operations granted by the **ServiceConnect** permission. These operations include receiving device-to-cloud messages, sending cloud-to-device messages, and so on. If you want to grant more granular access to your services, for example, limiting a service to only sending cloud-to-device messages, you can use Azure Active Directory. To learn more, see [Authenticate with Azure AD](authenticate-authorize-azure-ad.md).
104
104
105
105
## Use SAS tokens from devices
106
106
@@ -152,7 +152,7 @@ The two main scenarios for using shared access policies to access device functio
152
152
153
153
Since the shared access policy can potentially grant access to connect as any device, it is important to use the correct resource URI when creating SAS tokens. This setting is especially important for token services, which have to scope the token to a specific device using the resource URI. This point is less relevant for protocol gateways as they are already mediating traffic for all devices.
154
154
155
-
As an example, a token service using the pre-created shared access policy called **device** would create a token with the following parameters:
155
+
As an example, a token service using the precreated shared access policy called **device** would create a token with the following parameters:
* signing key: one of the keys of the `device` policy,
@@ -200,11 +200,11 @@ Here are the main steps of the token service pattern:
200
200
201
201
The token service can set the token expiration as desired. When the token expires, the IoT hub severs the device/module connection. Then, the device/module must request a new token from the token service. A short expiry time increases the load on both the device/module and the token service.
202
202
203
-
For a device/module to connect to your hub, you must still add it to the IoT Hub identity registry — even though it is using a token and not a key to connect. Therefore, you can continue to use per-device/per-module access control by enabling or disabling device/module identities in the identity registry. This approach mitigates the risks of using tokens with long expiry times.
203
+
For a device/module to connect to your hub, you must still add it to the IoT Hub identity registry—even though it is using a token and not a key to connect. Therefore, you can continue to use per-device/per-module access control by enabling or disabling device/module identities in the identity registry. This approach mitigates the risks of using tokens with long expiry times.
204
204
205
205
### Comparison with a custom gateway
206
206
207
-
The token service pattern is the recommended way to implement a custom identity registry/authentication scheme with IoT Hub. This pattern is recommended because IoT Hub continues to handle most of the solution traffic. However, if the custom authentication scheme is so intertwined with the protocol, you may require a *custom gateway* to process all the traffic. An example of such a scenario is using [Transport Layer Security (TLS) and pre-shared keys (PSKs)](https://tools.ietf.org/html/rfc4279). For more information, see [How an IoT Edge device can be used as a gateway](../iot-edge/iot-edge-as-gateway.md).
207
+
The token service pattern is the recommended way to implement a custom identity registry/authentication scheme with IoT Hub. This pattern is recommended because IoT Hub continues to handle most of the solution traffic. However, if the custom authentication scheme is so intertwined with the protocol, you may require a *custom gateway* to process all the traffic. An example of such a scenario is using [Transport Layer Security (TLS) and preshared keys (PSKs)](https://tools.ietf.org/html/rfc4279). For more information, see [How an IoT Edge device can be used as a gateway](../iot-edge/iot-edge-as-gateway.md).
208
208
209
209
## Generate SAS tokens
210
210
@@ -234,7 +234,7 @@ Here are the expected values:
234
234
| {URL-encoded-resourceURI} |Lower case URL-encoding of the lower case resource URI |
235
235
| {policyName} |The name of the shared access policy to which this token refers. Absent if the token refers to device-registry credentials. |
236
236
237
-
The URI prefix is computed by segment and not by character. For example `/a/b` is a prefix for `/a/b/c` but not for `/a/bc`.
237
+
The URI prefix is computed by segment and not by character. For example,`/a/b` is a prefix for `/a/b/c` but not for `/a/bc`.
238
238
239
239
### [Node.js](#tab/node)
240
240
@@ -367,7 +367,7 @@ For SASL PLAIN, the **username** can be:
367
367
*`{policyName}@sas.root.{iothubName}` if using IoT hub-level tokens.
368
368
*`{deviceId}@sas.{iothubname}` if using device-scoped tokens.
369
369
370
-
In both cases, the password field contains the token, as described in [IoT Hub SAS tokens](iot-hub-dev-guide-sas.md#sas-tokens).
370
+
In both cases, the password field contains the token, as described in [SAS token structure](#sas-token-structure).
371
371
372
372
HTTPS implements authentication by including a valid token in the **Authorization** request header.
0 commit comments