[ { "id": "9fbdd3f57deafc08", "type": "tab", "label": "User Management ASE Mosquitto", "disabled": false, "info": "", "env": [] }, { "id": "9d08dcc1d6da93f4", "type": "ui_form", "z": "9fbdd3f57deafc08", "name": "New user", "label": "", "group": "69ae86190d4eadd7", "order": 2, "width": 0, "height": 0, "options": [ { "label": "Username", "value": "Username", "type": "text", "required": true, "rows": null }, { "label": "Password", "value": "Password", "type": "password", "required": true, "rows": null }, { "label": "ClientID", "value": "ClientID", "type": "text", "required": false, "rows": null }, { "label": "Description title", "value": "Textname", "type": "text", "required": false, "rows": null }, { "label": "Description", "value": "Textdescription", "type": "text", "required": false, "rows": null } ], "formValue": { "Username": "", "Password": "", "ClientID": "", "Textname": "", "Textdescription": "" }, "payload": "", "submit": "submit", "cancel": "cancel", "topic": "", "topicType": "str", "splitLayout": "", "className": "", "x": 84, "y": 240, "wires": [ [ "3711eb142a27fd31", "49e737145eab4f54", "ca48c155d446edb2" ] ], "inputLabels": [ "aa" ], "outputLabels": [ "aa" ] }, { "id": "88376950bf613f47", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format new user payload ", "func": "var msg = {\n payload: {\n commands: [\n {\n \"command\": \"createClient\",\n \"username\": msg.payload.Username,\n \"password\": msg.payload.Password,\n \"clientid\": msg.payload.ClientID,\n\t\t\t \"textname\": msg.payload.Textname, \n \"textdescription\": msg.payload.Textdescription,\n\t\t\t \"groups\": [\n\t\t\t ],\n\t\t\t \"roles\": [\n\t\t\t\t { \"rolename\": msg.payload.Username.concat(\"_role\"), \"priority\": 0 }\n\t\t\t ]\n }\n ]\n }\n};\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 718, "y": 320, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "2aecbce52ca97912", "type": "mqtt out", "z": "9fbdd3f57deafc08", "name": "Dynamic security control", "topic": "$CONTROL/dynamic-security/v1", "qos": "2", "retain": "false", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "6c0c13a328d2378c", "x": 1286, "y": 480, "wires": [] }, { "id": "255fcd63d3387488", "type": "catch", "z": "9fbdd3f57deafc08", "name": "Catch error", "scope": null, "uncaught": false, "x": 84, "y": 88, "wires": [ [ "8669f263b392e9db" ] ] }, { "id": "30603217455d8705", "type": "ui_toast", "z": "9fbdd3f57deafc08", "position": "dialog", "displayTime": "5", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "className": "msg.error.message", "topic": "", "name": "Error Notification", "x": 698, "y": 88, "wires": [ [] ] }, { "id": "8669f263b392e9db", "type": "change", "z": "9fbdd3f57deafc08", "name": "Set payload as error message", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "error.message", "tot": "msg", "dc": true } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 386, "y": 88, "wires": [ [ "30603217455d8705" ] ] }, { "id": "79338504ed1eddba", "type": "mqtt in", "z": "9fbdd3f57deafc08", "name": "Response", "topic": "$CONTROL/dynamic-security/v1/response", "qos": "2", "datatype": "auto-detect", "broker": "6c0c13a328d2378c", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 84, "y": 856, "wires": [ [ "4f1d82b81f042382", "a5fdabb1abae1a6e", "f070ff4b26975684", "8b53a58acf784065" ] ] }, { "id": "377b761521508bb9", "type": "ui_button", "z": "9fbdd3f57deafc08", "name": "Refresh users list", "group": "ab99b1708f72e425", "order": 1, "width": 0, "height": 0, "passthru": true, "label": "Refresh users list", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "mi-refresh", "payload": "{\"commands\":[{\"command\":\"listClients\"}]}", "payloadType": "json", "topic": "$CONTROL/dynamic-security/v1", "topicType": "msg", "x": 702, "y": 760, "wires": [ [ "2aecbce52ca97912", "7aac58500a269ff4" ] ] }, { "id": "4f1d82b81f042382", "type": "function", "z": "9fbdd3f57deafc08", "name": "Extract users list & fill dropdown ui", "func": "let response_of = msg.payload.responses[0].command;\nif (response_of == \"listClients\") {\n var users = msg.payload.responses[0].data.clients; \n const index = users.indexOf(\"admin\");\n if (index > -1) {\n users.splice(index, 1); \n }\n msg.options = users;\n return msg;\n}\nreturn null;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 396, "y": 816, "wires": [ [ "06393fdc9c737c57" ] ] }, { "id": "06393fdc9c737c57", "type": "ui_dropdown", "z": "9fbdd3f57deafc08", "name": "Existing users", "label": "Existing users", "tooltip": "", "place": "Select user", "group": "ab99b1708f72e425", "order": 2, "width": 0, "height": 0, "passthru": true, "multiple": false, "options": [], "payload": "", "topic": "options", "topicType": "msg", "className": "", "x": 336, "y": 896, "wires": [ [ "1d4c2df0e173d2e3", "8bef671fa22d9d07" ] ] }, { "id": "9c1c4f045dee7138", "type": "ui_button", "z": "9fbdd3f57deafc08", "name": "Delete user", "group": "ab99b1708f72e425", "order": 6, "width": 0, "height": 0, "passthru": false, "label": "Delete selected user", "tooltip": "", "color": "", "bgcolor": "#FF6666", "className": "", "icon": "mi-delete", "payload": "user", "payloadType": "flow", "topic": "topic", "topicType": "msg", "x": 94, "y": 536, "wires": [ [ "545442acdd0b1a0d", "4798c117a3d42c70" ] ] }, { "id": "1d4c2df0e173d2e3", "type": "function", "z": "9fbdd3f57deafc08", "name": "Set flow.user var", "func": "flow.set(\"user\", msg.payload);\nreturn;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 688, "y": 920, "wires": [ [] ] }, { "id": "d82c6b29558cbc01", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format delete role payload", "func": "let user = flow.get(\"user\");\nvar msg = {\n payload: {\n commands: [\n {\n \"command\": \"deleteRole\",\n\t\t\t\t\"rolename\": user.concat(\"_role\")\n\t\t\t}\n\t\t]\n\t}\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 728, "y": 592, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "3711eb142a27fd31", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format new role payload ", "func": "var msg = {\n payload: {\n commands: [\n {\n \"command\": \"createRole\",\n \"rolename\": msg.payload.Username.concat(\"_role\"),\n \"textname\": \"\", \n\t\t\t \"textdescription\": \"\", \n\t\t\t \"acls\": [\n { \"acltype\": \"publishClientSend\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true }\n ]\n }\n ]\n }\n};\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 718, "y": 216, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "49e737145eab4f54", "type": "delay", "z": "9fbdd3f57deafc08", "name": "Delay user def. after group", "pauseType": "delay", "timeout": "500", "timeoutUnits": "milliseconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 376, "y": 344, "wires": [ [ "88376950bf613f47", "94124ffc77e8335d" ] ] }, { "id": "4798c117a3d42c70", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format delete user payload", "func": "let user = flow.get(\"user\");\nvar msg = {\n payload: {\n commands: [\n {\n \"command\": \"deleteClient\",\n\t\t\t\t\"username\": user\n\t\t\t}\n\t\t]\n\t}\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 728, "y": 536, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "545442acdd0b1a0d", "type": "delay", "z": "9fbdd3f57deafc08", "name": "Delay role dele. after user", "pauseType": "delay", "timeout": "500", "timeoutUnits": "milliseconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 366, "y": 592, "wires": [ [ "d82c6b29558cbc01" ] ] }, { "id": "8d3eb0f225aaba0e", "type": "ui_button", "z": "9fbdd3f57deafc08", "name": "Disable user", "group": "ab99b1708f72e425", "order": 5, "width": 0, "height": 0, "passthru": false, "label": "Disable selected user", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "mi-person_off", "payload": "user", "payloadType": "flow", "topic": "topic", "topicType": "msg", "x": 94, "y": 424, "wires": [ [ "b97f2e66e9ea4702" ] ] }, { "id": "b97f2e66e9ea4702", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format disable user payload", "func": "let user = flow.get(\"user\");\nvar msg = {\n payload: {\n commands: [\n {\n \"command\": \"disableClient\",\n\t\t\t\t\"username\": user\n\t\t\t}\n\t\t]\n\t}\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 728, "y": 424, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "2272690dede6a475", "type": "ui_button", "z": "9fbdd3f57deafc08", "name": "Enable user", "group": "ab99b1708f72e425", "order": 4, "width": 0, "height": 0, "passthru": false, "label": "Enable selected user", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "mi-person", "payload": "user", "payloadType": "flow", "topic": "topic", "topicType": "msg", "x": 94, "y": 480, "wires": [ [ "1b7e77253c8b385d" ] ] }, { "id": "1b7e77253c8b385d", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format enable user payload", "func": "let user = flow.get(\"user\");\nvar msg = {\n payload: {\n commands: [\n {\n \"command\": \"enableClient\",\n\t\t\t\t\"username\": user\n\t\t\t}\n\t\t]\n\t}\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 728, "y": 480, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "8bef671fa22d9d07", "type": "function", "z": "9fbdd3f57deafc08", "name": "Format get client info", "func": "let user = msg.payload;\nvar msg = {\n payload: {\n commands: [\n {\n \"command\": \"getClient\",\n\t\t\t\t\"username\": user\n\t\t\t}\n\t\t]\n\t}\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 708, "y": 872, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "f070ff4b26975684", "type": "function", "z": "9fbdd3f57deafc08", "name": "Extract users info & fill text field", "func": "let response_of = msg.payload.responses[0].command;\nif (response_of == \"getClient\") {\n let user = msg.payload.responses[0].data.client.username; \n let disabled = msg.payload.responses[0].data.client.disabled; \n let role = msg.payload.responses[0].data.client.roles[0].rolename; \n msg = {\n payload: {\n \"username\": user,\n \"disabled\": disabled,\n \"role\": role\n }\n }\n return msg;\n}\nreturn null;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 386, "y": 976, "wires": [ [ "934816df4e8f7fe2" ] ] }, { "id": "a5fdabb1abae1a6e", "type": "function", "z": "9fbdd3f57deafc08", "name": "Check command", "func": "\nlet response_of = msg.payload.responses[0].command;\nif ((response_of == \"createClient\") || (response_of == \"deleteClient\") || (response_of == \"enableClient\") || (response_of == \"disableClient\")) {\n return msg;\n}\n\nreturn null;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 346, "y": 760, "wires": [ [ "377b761521508bb9" ] ] }, { "id": "7aac58500a269ff4", "type": "function", "z": "9fbdd3f57deafc08", "name": "Clean client info", "func": "msg = {\n payload: {\n \"username\": \"\",\n \"disabled\": \"\",\n \"role\": \"\"\n }\n}\nreturn msg;\n", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 688, "y": 816, "wires": [ [ "934816df4e8f7fe2" ] ] }, { "id": "934816df4e8f7fe2", "type": "ui_template", "z": "9fbdd3f57deafc08", "group": "ab99b1708f72e425", "name": "User Info", "order": 3, "width": 0, "height": 0, "format": "
| Role Name | \nACL Type | \nTopic | \nPriority | \nAllow | \n
|---|---|---|---|---|
| ${role.rolename} | `;\n }\n\n // Aggiunta dei dettagli ACL\n html += `${acl.acltype} | \n${acl.topic} | \n${acl.priority} | \n${acl.allow} | \n