Description
Milesight UG6X/UG56 gateway support build-in Node-red. This example explains how to add a read-only user to Node-Red. The read-only user only has access to Node-Red, but does not have permission to modify flow and deploy flow.
Requirement
- Milesight Gateway: UG56/UG65/UG67
Configuration
Step 1: Launch Node-RED and Import Flow Example
1. Go to App > Node-RED page to enable Node-RED program and wait for a while to load the program, click Launch button to start Node-RED web GUI.
2. Log in the Node-RED web GUI. The account information is the same as gateway web GUI.
3. Click Import to import the node-red flow example by pasting the content or import the json format file.
Step 2: Node-RED Configuration
Flow structure:
Content:
[{"id":"bf264d5544905d3b","type":"tab","label":"flow 1","disabled":false,"info":"","env":[]},{"id":"cd687a0b8db74ede","type":"inject","z":"bf264d5544905d3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":240,"wires":[["8be44b847657248c"]]},{"id":"8be44b847657248c","type":"exec","z":"bf264d5544905d3b","command":"cd /etc/node_red;sed -i '122i \\ \\ \\ \\ },\\n\\ \\ \\ \\ {\\n\\ \\ \\ \\ \\ \\ \\ \\ username: \"admin111\",\\n\\ \\ \\ \\ \\ \\ \\ \\ password: \"$2a$08$bir1pFwfBQlfdjOt1pn0xeNkW9Cdl6vikhrzDULwBO4sOwbaQKbnC\",\\n\\ \\ \\ \\ \\ \\ \\ \\ permissions: \"read\"\\n' settings.js","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":780,"y":300,"wires":[["b0fed19a0be833a8"],[],[]]},{"id":"ebf87dce3f90dff3","type":"comment","z":"bf264d5544905d3b","name":"Adding a read-only user for Node-red access","info":"","x":430,"y":260,"wires":[]},{"id":"b0fed19a0be833a8","type":"debug","z":"bf264d5544905d3b","name":"debug 15","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1400,"y":380,"wires":[]},{"id":"e249cef874c6e369","type":"inject","z":"bf264d5544905d3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":120,"wires":[["08517d2c5d3310a9"]]},{"id":"08517d2c5d3310a9","type":"exec","z":"bf264d5544905d3b","command":"echo -e \"password111\" | node-red admin hash-pw","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":440,"y":120,"wires":[["130ffd59d3dbb671"],[],[]]},{"id":"fb5b46f3918a4c74","type":"comment","z":"bf264d5544905d3b","name":"Generate new hash encryption for Read-only password \"password111\"","info":"","x":470,"y":80,"wires":[]},{"id":"130ffd59d3dbb671","type":"debug","z":"bf264d5544905d3b","name":"debug 16","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":120,"wires":[]},{"id":"fa7ddcdaad853b5f","type":"inject","z":"bf264d5544905d3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":480,"wires":[["03b016ea8ba30e3c"]]},{"id":"03b016ea8ba30e3c","type":"exec","z":"bf264d5544905d3b","command":"reboot","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":310,"y":480,"wires":[["8a130545d95fce67"],[],[]]},{"id":"8a130545d95fce67","type":"debug","z":"bf264d5544905d3b","name":"debug 17","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":500,"wires":[]},{"id":"b49f9ec527739b49","type":"comment","z":"bf264d5544905d3b","name":"Trigger gateway reboot","info":"","x":340,"y":440,"wires":[]}]
Step 3: Deploy and Check Result
1. Click Deploy to save all node-red configurations.
2. Click 1st rule to create a new password for the read-only user and generate a corresponding hash value for that password. ‘password111’ can be changed to the password you want to set for read-only user.
3. Copy the hash password generated in the previous command into the 2nd rule ,and click 2nd rule to trigger.
4. Once the changes are complete, you need to click on the 3rd rule to trigger a gateway reboot for the new configuration to take effect.
5. After rebooting, you could log in to Node-Red with Read-only username or password. In this example is “admin111” and “password111”.
Under read-only user privileges, the user can only view the node, can not deploy, when clicking on deploy will not take effect.
-------END-----