[ { "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": "Description title", "value": "Textname", "type": "text", "required": false, "rows": null }, { "label": "Description", "value": "Textdescription", "type": "text", "required": false, "rows": null } ], "formValue": { "Username": "", "Password": "", "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": "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 \"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\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true },\n { \"acltype\": \"publishClientReceive\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true },\n { \"acltype\": \"subscribeLiteral\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true },\n { \"acltype\": \"subscribePattern\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true },\n { \"acltype\": \"unsubscribeLiteral\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true },\n { \"acltype\": \"unsubscribePattern\", \"topic\": msg.payload.Username.concat(\"/#\"), \"priority\": 0, \"allow\": true }\n ]\n },\n {\n \"command\": \"createClient\",\n \"username\": msg.payload.Username,\n \"password\": msg.payload.Password,\n \"clientid\": msg.payload.Username.concat(\"_client\"),\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\": msg.payload.Username.concat(\"_client_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": "
\n \n
\n
\n\n
\n \n
\n
\n\n
\n \n
\n
\n\n", "storeOutMessages": false, "fwdInMessages": true, "resendOnRefresh": false, "templateScope": "local", "className": "", "x": 668, "y": 688, "wires": [ [] ] }, { "id": "5cc1500ac9ea0f30", "type": "ui_ui_control", "z": "9fbdd3f57deafc08", "name": "UI action", "events": "all", "x": 84, "y": 880, "wires": [ [ "377b761521508bb9", "87774004a047169f" ] ] }, { "id": "87774004a047169f", "type": "ui_button", "z": "9fbdd3f57deafc08", "name": "Refresh roles info", "group": "550aa2ca318ab1ad", "order": 1, "width": 0, "height": 0, "passthru": true, "label": "Refresh roles info", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "mi-refresh", "payload": "{\"commands\":[{\"command\":\"listRoles\",\"verbose\":true,\"count\":-1,\"offset\":0}]}", "payloadType": "json", "topic": "$CONTROL/dynamic-security/v1", "topicType": "msg", "x": 698, "y": 880, "wires": [ [ "2aecbce52ca97912" ] ] }, { "id": "8b53a58acf784065", "type": "function", "z": "9fbdd3f57deafc08", "name": "Extract roles info & fill text field", "func": "let response_of = msg.payload.responses[0].command;\nif (response_of == \"listRoles\") {\n const roles = msg.payload.responses[0].data.roles;\n // Creazione della struttura HTML per la tabella\n let html = `\n \n \n \n \n \n \n \n \n \n `;\n\n // Iterazione sui ruoli\n roles.forEach(role => {\n const rowCount = role.acls.length; // Numero di ACL per il ruolo\n role.acls.forEach((acl, index) => {\n html += ``;\n\n // Solo la prima riga include il nome del ruolo con rowspan\n if (index === 0) {\n html += ``;\n }\n\n // Aggiunta dei dettagli ACL\n html += `\n \n \n \n `;\n });\n });\n\n html += `
Role NameACL TypeTopicPriorityAllow
${role.rolename}${acl.acltype}${acl.topic}${acl.priority}${acl.allow}
`;\n return msg = {\n payload: {\n \"table\": html\n }\n }\n}\n\nreturn null;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 386, "y": 624, "wires": [ [ "b711bce152685dec" ] ] }, { "id": "b711bce152685dec", "type": "ui_template", "z": "9fbdd3f57deafc08", "group": "550aa2ca318ab1ad", "name": "Roles and ACLs table", "order": 1, "width": "0", "height": "0", "format": "
\nTabella JSON con celle unite\n", "storeOutMessages": false, "fwdInMessages": false, "resendOnRefresh": false, "templateScope": "local", "className": "", "x": 708, "y": 624, "wires": [ [] ] }, { "id": "b27b626c8de3514b", "type": "http request", "z": "9fbdd3f57deafc08", "name": "Add password to wallet", "method": "POST", "ret": "txt", "paytoqs": "body", "url": "http://localhost:5000/add", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [ { "keyType": "Content-Type", "keyValue": "", "valueType": "application/json", "valueValue": "" } ], "x": 1270, "y": 112, "wires": [ [] ] }, { "id": "70ca52648a2c8fa5", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to add password to wallet", "func": "var msg = {\n payload: {\n \"master_password\": \"Ase#2024@wallet!\",\n \"site\": msg.payload.Username.concat(\"_ase_site\"),\n \"username\": msg.payload.Username.concat(\"_ase\"),\n \"password\": msg.payload.Password.concat(\"AsE\")\n }\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 778, "y": 112, "wires": [ [ "b27b626c8de3514b" ] ] }, { "id": "7b9944c244c48572", "type": "function", "z": "9fbdd3f57deafc08", "name": "Make msg payload to delete password on wallet", "func": "let user = flow.get(\"user\");\nvar msg = {\n payload: {\n \"master_password\": \"Ase#2024@wallet!\",\n \"site\": user.concat(\"_ase_site\"),\n }\n}\nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 788, "y": 240, "wires": [ [ "5f57768fa11f73b8" ] ] }, { "id": "5f57768fa11f73b8", "type": "http request", "z": "9fbdd3f57deafc08", "name": "Delete password on wallet", "method": "POST", "ret": "txt", "paytoqs": "query", "url": "http://localhost:5000/delete", "tls": "", "persist": false, "proxy": "", "insecureHTTPParser": false, "authType": "", "senderr": false, "headers": [ { "keyType": "Content-Type", "keyValue": "", "valueType": "application/json", "valueValue": "" } ], "x": 1270, "y": 240, "wires": [ [] ] }, { "id": "69ae86190d4eadd7", "type": "ui_group", "name": "Define new user", "tab": "f47c763c366069c9", "order": 1, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "6c0c13a328d2378c", "type": "mqtt-broker", "name": "mosquitto-ase", "broker": "209.227.230.114", "port": "1883", "clientid": "nodered", "autoConnect": true, "usetls": false, "protocolVersion": "5", "keepalive": "60", "cleansession": false, "autoUnsubscribe": true, "birthTopic": "", "birthQos": "0", "birthRetain": "false", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closeRetain": "false", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willRetain": "false", "willPayload": "", "willMsg": {}, "userProps": "", "sessionExpiry": "" }, { "id": "ab99b1708f72e425", "type": "ui_group", "name": "Manage existing users", "tab": "204076c20d6cbcab", "order": 2, "disp": true, "width": "6", "collapse": false, "className": "" }, { "id": "550aa2ca318ab1ad", "type": "ui_group", "name": "Roles and ACLs table ", "tab": "ff03baaa9b35bf68", "order": 1, "disp": true, "width": "14", "collapse": false, "className": "" }, { "id": "f47c763c366069c9", "type": "ui_tab", "name": "Define new user", "icon": "fa-user", "order": 1, "disabled": false, "hidden": false }, { "id": "204076c20d6cbcab", "type": "ui_tab", "name": "Manage existing users", "icon": "fa-users", "order": 2, "disabled": false, "hidden": false }, { "id": "ff03baaa9b35bf68", "type": "ui_tab", "name": "Roles and ACLs table informations", "icon": "fa-info", "order": 3, "disabled": false, "hidden": false } ]