[ { "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": 1, "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": "Topic patterns", "value": "Topic", "type": "text", "required": false, "rows": null }, { "label": "Client ID", "value": "Client_id", "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": "", "Topic": "", "Client_id": "", "Textname": "", "Textdescription": "" }, "payload": "", "submit": "submit", "cancel": "cancel", "topic": "", "topicType": "str", "splitLayout": "", "className": "", "x": 84, "y": 144, "wires": [ [ "3711eb142a27fd31", "70ca52648a2c8fa5" ] ], "inputLabels": [ "aa" ], "outputLabels": [ "aa" ] }, { "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": 1278, "y": 560, "wires": [] }, { "id": "255fcd63d3387488", "type": "catch", "z": "9fbdd3f57deafc08", "name": "Catch error", "scope": null, "uncaught": false, "x": 84, "y": 24, "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": 24, "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": 24, "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": 624, "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": 698, "y": 816, "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": 496, "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": 456, "y": 560, "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": 272, "wires": [ [ "4798c117a3d42c70", "7b9944c244c48572" ] ] }, { "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": 698, "y": 496, "wires": [ [] ] }, { "id": "3711eb142a27fd31", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to create roles and users", "func": "let Topic = \"\";\nif (msg.payload.Topic !== \"\") {\n Topic = msg.payload.Topic;\n} else {\n Topic = msg.payload.Username.concat(\"/#\");\n}\nlet Client_id = \"\";\nlet Client_id_ase = \"\";\nif (msg.payload.Client_id !== \"\") {\n Client_id = msg.payload.Client_id;\n Client_id_ase = msg.payload.Client_id.concat(\"_ase\");\n}\nvar 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\": Topic, \"priority\": 0, \"allow\": true }\n ]\n },\n {\n \"command\": \"createRole\",\n \"rolename\": msg.payload.Username.concat(\"_ase_role\"),\n \"textname\": \"\", \n\t\t\t \"textdescription\": \"\", \n\t\t\t \"acls\": [\n { \"acltype\": \"publishClientSend\", \"topic\": Topic, \"priority\": 0, \"allow\": true },\n { \"acltype\": \"publishClientReceive\", \"topic\": Topic, \"priority\": 0, \"allow\": true },\n { \"acltype\": \"subscribeLiteral\", \"topic\": Topic, \"priority\": 0, \"allow\": true },\n { \"acltype\": \"subscribePattern\", \"topic\": Topic, \"priority\": 0, \"allow\": true },\n { \"acltype\": \"unsubscribeLiteral\", \"topic\": Topic, \"priority\": 0, \"allow\": true },\n { \"acltype\": \"unsubscribePattern\", \"topic\": Topic, \"priority\": 0, \"allow\": true }\n ]\n },\n {\n \"command\": \"createClient\",\n \"username\": msg.payload.Username,\n \"password\": msg.payload.Password,\n \"clientid\": Client_id,\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 \"command\": \"createClient\",\n \"username\": msg.payload.Username.concat(\"_ase\"),\n \"password\": msg.payload.Password.concat(\"AsE\"),\n \"clientid\": Client_id_ase,\n \"textname\": msg.payload.Textname.concat(\" ASE subscriber\"), \n \"textdescription\": msg.payload.Textdescription.concat(\" ASE subscriber\"),\n\t\t\t \"groups\": [\n\t\t\t ],\n\t\t\t \"roles\": [\n\t\t\t\t { \"rolename\": msg.payload.Username.concat(\"_ase_role\"), \"priority\": 0 }\n\t\t\t ]\n }\n ]\n }\n};\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 778, "y": 176, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "4798c117a3d42c70", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to delete role and user", "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 {\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": 768, "y": 304, "wires": [ [ "2aecbce52ca97912" ] ] }, { "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": 368, "wires": [ [ "b97f2e66e9ea4702" ] ] }, { "id": "b97f2e66e9ea4702", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to disable user", "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": 748, "y": 368, "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": 432, "wires": [ [ "1b7e77253c8b385d" ] ] }, { "id": "1b7e77253c8b385d", "type": "function", "z": "9fbdd3f57deafc08", "name": "make msg payload to enable user", "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": 748, "y": 432, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "8bef671fa22d9d07", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to 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": 748, "y": 560, "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": 688, "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": 816, "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": 336, "y": 752, "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