Device Authorization and Authentication

The client authorization logic cross-checks the metadata provided by the connecting device through its client certificate with the resources the connecting device is trying to access.

In each client connection, the following authorization checks are performed:
  • The instanceId included in the certificate must match the ID of the instance to which the IoT Gateway belongs.

  • The deviceAlternateId included in the certificate must match the ID of the instance to which the IoT Gateway belongs.

  • The deviceAlternateId included in the certificate must match the MQTT clientId retrieved from the MQTT metadata. This constraint can be relaxed in case the connecting device has the authorization type router, as described in section Connection as a Router Device.

If an MQTT client attempts to post measurement data for ingestion, the following authorization checks are performed:
  • The topic to which the measurement data is published must match the structure that is defined for the data ingestion topic. For more information, please refer to section Measure Message Format (JSON).

  • The deviceAlternateId included in the certificate must match the alternateId value that is specified in the measure ingestion topic.

If an MQTT client attempts to subscribe to the command topic, the following authorization checks are performed:
  • The target topic must match the structure that is defined for the command topic. For more information, please refer to section Command Message Format (JSON).

  • The deviceAlternateId included in the certificate must match the alternateId value that is specified in the command topic.

Connection as a Router Device

If the device has the authorization type router, it is allowed to send data and subscribe to the command topic on behalf of another device managed by the same gateway.

In this case, use the certificate of the router device. In the payload, use the device Alternate ID, capability Alternate ID, and sensor Alternate ID of the other device that you want to send measures to. For more information, please refer to the tutorial Create a Device Model using API.

If the authorization type is router, the match between the deviceAlternateId and the MQTT clientId is not enforced. This allows a router device to connect using any value for the MQTT clientId.

Certificate Structure

Data ingestion on the IoT Gateway Cloud endpoints uses TLS with mutual authentication by leveraging X.509 client certificates associated with single devices. The certificate field has the following structure:
CN=deviceAlternateId:<…>|gatewayId:<…>|tenantId:<…>|instanceId:<…>
The deviceAlternateId represents the alternate ID of the targeted device and the instanceId represents the ID associated with Device Connectivity instance that the IoT Gateway Cloud belongs to.
For example, the subject of the certificate could look as follows: