I am preparing an integration tool to connect Django with Node-RED, which will allow for significant flexibility in granting permissions and access rights for users to control devices, check their statuses, and track actions taken by individuals. For example, in a factory setting with an entire team, not every person will have the same permissions.
I have also modified the Node-RED instance to accept only registered users from Django. This means that even if someone manages to access the IP address of Node-RED, it will only function with full reliance on Django for access rights. Node-RED can only be opened within an iframe on a Django page because it depends on sending the user's session ID to Django to determine whether that user has the right to access it.
I am currently adding functionality for cases where Node-RED and Django are in different locations using the internet instead of a local network. I am using encryption techniques to ensure that message information cannot be revealed under any circumstances, employing AES with Base64. However, when encrypting using Django with Python, I cannot decrypt it using Node-RED's JavaScript; the output is nothing, and the same happens in reverse, despite using the same settings on both sides. Encryption is just an option that I will leave out, as it may consume resources when it is not essential, such as when both are on the same local network or server.
I am happy to hear your suggestions.
there are two tab one for django and another from node red
This example demonstrates my ability to pass data within Node-RED messages. In this example, I was able to add the user's username.
json
{"payload":false,"group_id":"Toggle","user":"taha","_msgid":"dd78072b9895ed10","_event":"node:8c17425cf6b74635","is_disconnected":false}
Note: This is done through the backend, not the frontend.
Note: The group_id
works as the group name for the channel and as the key for caching the device status.
Note: Devices can be added or removed, and the number of points (here, points refer to the last status of the device) can be increased or decreased without stopping Django or modifying it. In some cases, I store the last 20 statuses, similar to a chart. There is a table through which devices can be added or removed, as well as changing the number of points.