From 08f6e80f4f8ffed3a5ccae3d96c2609bfd5960ba Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 15 Dec 2024 10:43:04 +0100 Subject: [PATCH] initial commit --- ase_user_nodered.json | 772 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 772 insertions(+) create mode 100644 ase_user_nodered.json diff --git a/ase_user_nodered.json b/ase_user_nodered.json new file mode 100644 index 0000000..dd500c8 --- /dev/null +++ b/ase_user_nodered.json @@ -0,0 +1,772 @@ +[ + { + "id": "9fbdd3f57deafc08", + "type": "tab", + "label": "Flow 1", + "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": "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": 80, + "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": 650, + "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": 1210, + "y": 480, + "wires": [] + }, + { + "id": "255fcd63d3387488", + "type": "catch", + "z": "9fbdd3f57deafc08", + "name": "Catch error", + "scope": null, + "uncaught": false, + "x": 80, + "y": 160, + "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": 630, + "y": 160, + "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": 350, + "y": 160, + "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": 80, + "y": 780, + "wires": [ + [ + "4f1d82b81f042382", + "a5fdabb1abae1a6e", + "f070ff4b26975684", + "d4c0e6d5f0757ef5" + ] + ] + }, + { + "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": 630, + "y": 660, + "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": 380, + "y": 720, + "wires": [ + [ + "06393fdc9c737c57" + ] + ] + }, + { + "id": "06393fdc9c737c57", + "type": "ui_dropdown", + "z": "9fbdd3f57deafc08", + "name": "", + "label": "Existing users dropdown ui", + "tooltip": "", + "place": "Select user", + "group": "ab99b1708f72e425", + "order": 2, + "width": 0, + "height": 0, + "passthru": true, + "multiple": false, + "options": [], + "payload": "", + "topic": "options", + "topicType": "msg", + "className": "", + "x": 360, + "y": 780, + "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": 90, + "y": 540, + "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": 630, + "y": 800, + "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": 660, + "y": 600, + "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": 650, + "y": 220, + "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": 340, + "y": 340, + "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": 660, + "y": 540, + "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": 350, + "y": 600, + "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": 90, + "y": 420, + "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": 660, + "y": 420, + "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": 90, + "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": 660, + "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": 640, + "y": 760, + "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": 370, + "y": 860, + "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": 330, + "y": 660, + "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": 920, + "y": 800, + "wires": [ + [ + "934816df4e8f7fe2" + ] + ] + }, + { + "id": "934816df4e8f7fe2", + "type": "ui_template", + "z": "9fbdd3f57deafc08", + "group": "ab99b1708f72e425", + "name": "User Info", + "order": 3, + "width": "6", + "height": "2", + "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": 600, + "y": 860, + "wires": [ + [] + ] + }, + { + "id": "ca48c155d446edb2", + "type": "function", + "z": "9fbdd3f57deafc08", + "name": "Format new ase role payload ", + "func": "var msg = {\n payload: {\n commands: [\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 }\n};\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 660, + "y": 260, + "wires": [ + [ + "2aecbce52ca97912" + ] + ] + }, + { + "id": "94124ffc77e8335d", + "type": "function", + "z": "9fbdd3f57deafc08", + "name": "Format new ase user payload ", + "func": "var msg = {\n payload: {\n commands: [\n {\n \"command\": \"createClient\",\n \"username\": msg.payload.Username.concat(\"_ase\"),\n \"password\": msg.payload.Password.concat(\"AsE\"),\n \"clientid\": msg.payload.ClientID.concat(\"_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": 670, + "y": 360, + "wires": [ + [ + "2aecbce52ca97912" + ] + ] + }, + { + "id": "d4c0e6d5f0757ef5", + "type": "debug", + "z": "9fbdd3f57deafc08", + "name": "debug 1", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 220, + "y": 920, + "wires": [] + }, + { + "id": "ecbcbb721db680f4", + "type": "ui_spacer", + "z": "9fbdd3f57deafc08", + "name": "spacer", + "group": "69ae86190d4eadd7", + "order": 2, + "width": "1", + "height": "1" + }, + { + "id": "69ae86190d4eadd7", + "type": "ui_group", + "name": "Define new user", + "tab": "f47c763c366069c9", + "order": 1, + "disp": true, + "width": "6", + "collapse": true, + "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": "f47c763c366069c9", + "order": 2, + "disp": true, + "width": "6", + "collapse": true, + "className": "" + }, + { + "id": "f47c763c366069c9", + "type": "ui_tab", + "name": "Home", + "icon": "mi-dashboard", + "disabled": false, + "hidden": false + } +] \ No newline at end of file