ux4iot
  • Introduction
  • Quickstart
  • Concepts
  • How Ux4iot works
  • REST API Reference
  • Configuration Options
  • Create your ux4iot Instance
  • EventHub / IoTHub
    • Configure your existing IoT Hub
    • Create IoT Hub and linked ux4iot
    • Using a separate Event Hub
  • ux4iot-react
    • Initialization
    • Hooks
    • Grant Request Function
    • Tutorial using create-react-app
  • Implementing your custom security backend
    • Introduction
    • Security Backend
    • Security Backend Example - Azure Function
    • ux4iot-admin-node
  • Resources
    • Pricing
    • Performance
    • Limitations
    • Known Bugs & Nice to know's
    • Changelog
  • Made with ❤️ at Device Insight
Powered by GitBook
On this page

Was this helpful?

  1. Implementing your custom security backend

ux4iot-admin-node

PreviousSecurity Backend Example - Azure FunctionNextPricing

Last updated 1 year ago

Was this helpful?

The Node Admin SDK can be found on .

First, add the dependency:

npm install ux4iot-admin-node
yarn add ux4iot-admin-node

Initialize the SDK using the connection string. You can retrieve the connection string from the Azure portal.

const Ux4iotAdminSDK = require('ux4iot-admin');
const sdk = new Ux4iotAdminSDK({
    connectionString: "HostName=...;Key=secret";
});

Now you can whitelist grant requests using:

sdk.grant(grantRequest);

Usually, the grantRequest will be exactly identical to the body received by the custom security backend. In the security backend, you merely decide which grant requests to forward and which not to forward.

If you want to revoke the grant at a later point in time, you can do this using:

sdk.revokeGrant({
  sessionId: "ijfoewio22490320",
  deviceId: "d123",
  grantType: "subscribeToTelemetry"
});

You can revoke all grants for a session with this:

sdk.revokeSession("ijfoewio22490320");

You can even revoke all sessions:

sdk.revokeAllSessions();
GitHub