From bc6f255e28c3aa2d95b9df8f491128e734076069 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 17 Aug 2023 11:41:55 +0930 Subject: [PATCH] refactor(config): move config to home flow !8 --- flows.json | 256 +++++++---------------------------------------------- 1 file changed, 32 insertions(+), 224 deletions(-) diff --git a/flows.json b/flows.json index 7fdabb7..35c89f4 100644 --- a/flows.json +++ b/flows.json @@ -453,34 +453,11 @@ "h": 1334, "info": "# Authentication\n\nThis group is responsible for ensuring the user is authorized to access the system. \nAny valid user account that authenticates to the system is authorized.\n\nFrom entry the next step in the process is cookie validation.\n\n## Input Data\n\nThis group has two paths for entry: \n\n1. Cookie Found - `msg.req.cookies.auth` key exists\n\n > Value is the session name.\n\n1. No Cookie Found - `msg.req.cookies.auth` key does not exist\n\n > User to be redirected to authentication method\n\n\n## Output Data\n\nThis group does not always not return data. \nData returned is only stored in `msg.session`.\n\n### Authenticated User\n\n`msg.session` is returned with the Authentication data contained. \n\nThis data will either be from a stored session (user authenticated previously) or be created via the authentication method.\nThere are two session types and they are `token` and `oauth2`. Session types are directly tied to the method of authentication.\n\n`msg.session` structure\n\n``` json\n{\n \"session\": {\n \"datetime\": \"{session expiry}\",\n \"type\": \"token\",\n \"user\"{\n \"username\": \"barny.gumble\",\n \"fname\": \"Barny\",\n \"lname\": \"Gumble\",\n \"mail\": \"barney.gumble@dinomail.com\"\n },\n \"oauth2\": {\n // Only if type=oauth2\n }\n }\n}\n\n```\n\n### Non-Authenticated User\n\nNo data is returned if the user is not authenticated. The absense of `msg.session` denotes an unauthenticated user.\n" }, - { - "id": "8a2206d682028469", - "type": "group", - "z": "42b9663b67dbd983", - "name": "Development: Create Config File", - "style": { - "stroke": "#0070c0", - "fill": "#b797cf", - "label": true, - "color": "#000000" - }, - "nodes": [ - "e36b580c48d33ca0", - "497a482f9881a318", - "170b86b633c5ccd7", - "befac3bb99b2c2cc" - ], - "x": 1314, - "y": 199, - "w": 752, - "h": 82, - "info": "# Config File\n\nThis group contains the configuration for Self-Service.\n\n\n## Structure\n\nExample:\n``` json\n{\n \"auth_method\": [ \"oauth\", \"token\" ],\n \"developer_mode\": false,\n \"html\": {\n \"logo\": \"http://nofusscomputing.com/assets/nfc_revamp_dark.png\",\n \"logo_width\": 282,\n \"logo_height\": 90\n },\n \"http_path\": \"/\",\n \"itsm\": {\n \"api_url\": \"http://glpi/apirest.php/\",\n \"create_ticket\": true,\n \"create_ticket_task\": true,\n \"platform\": \"glpi\",\n \"search\": true,\n \"human_task_duration_time\": 300,\n \"ticket\": {\n \"approval_required\": 0,\n \"category_id\": 6,\n \"entity_id\": 1,\n \"requesttype_id\": 6,\n \"task_category_id\": 2\n }\n },\n \"paths\": {\n \"user_data\": \"data/users/\",\n \"token_sessions\": \"data/sessions/\"\n }\n}\n```\n\n**Note:** paths must not begin with `/` however must end with `/` this includes no sub path i.e. `/`\n\n**Note:** `http_path` must begin and end with `/`" - }, { "id": "b994fe21efb223a9", "type": "group", "z": "379c65a27117b46c", - "name": "Automagic: Read Config file", + "name": "Automagic: Config to global", "style": { "stroke": "#6f2fa0", "fill": "#92d04f", @@ -489,22 +466,19 @@ }, "nodes": [ "c7ca92d48206b4b2", - "7df31641fc2fe59a", - "d109fc9821987d4f", - "e9127065159b9f0f", "de01a4559aecf1c4", - "36cf43c754570ebd", "842ade29052f7e66", "957b63c9fc58a139", "02812e8708980b09", "e83ed4274d3959f3", "06b5d27bbf1e5b16", "32d8df5c0bb564cb", - "fb7fea44905cf7a4" + "fb7fea44905cf7a4", + "2d4bed7c63632c6c" ], "x": 154, "y": 59, - "w": 1432, + "w": 1032, "h": 182 }, { @@ -2136,7 +2110,7 @@ "type": "junction", "z": "379c65a27117b46c", "g": "b994fe21efb223a9", - "x": 1340, + "x": 940, "y": 140, "wires": [ [ @@ -2149,7 +2123,7 @@ "type": "junction", "z": "379c65a27117b46c", "g": "b994fe21efb223a9", - "x": 1000, + "x": 600, "y": 140, "wires": [ [ @@ -2158,19 +2132,6 @@ ] ] }, - { - "id": "32d8df5c0bb564cb", - "type": "junction", - "z": "379c65a27117b46c", - "g": "b994fe21efb223a9", - "x": 460, - "y": 100, - "wires": [ - [ - "7df31641fc2fe59a" - ] - ] - }, { "id": "e551d77d5412aced", "type": "junction", @@ -2968,80 +2929,7 @@ "y": 100, "wires": [ [ - "32d8df5c0bb564cb" - ] - ] - }, - { - "id": "7df31641fc2fe59a", - "type": "file in", - "z": "379c65a27117b46c", - "g": "b994fe21efb223a9", - "name": "Open Config File", - "filename": "filename", - "filenameType": "msg", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "none", - "allProps": false, - "x": 630, - "y": 100, - "wires": [ - [ - "d109fc9821987d4f" - ] - ] - }, - { - "id": "d109fc9821987d4f", - "type": "json", - "z": "379c65a27117b46c", - "g": "b994fe21efb223a9", - "name": "", - "property": "payload", - "action": "obj", - "pretty": false, - "x": 770, - "y": 100, - "wires": [ - [ - "e9127065159b9f0f" - ] - ] - }, - { - "id": "e9127065159b9f0f", - "type": "change", - "z": "379c65a27117b46c", - "g": "b994fe21efb223a9", - "name": "global.config", - "rules": [ - { - "t": "set", - "p": "config", - "pt": "global", - "to": "payload", - "tot": "msg" - }, - { - "t": "set", - "p": "CurrentGlobalConfig", - "pt": "msg", - "to": "config", - "tot": "global" - } - ], - "action": "", - "property": "", - "from": "", - "to": "", - "reg": false, - "x": 890, - "y": 100, - "wires": [ - [ - "06b5d27bbf1e5b16" + "2d4bed7c63632c6c" ] ] }, @@ -3059,26 +2947,10 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1470, + "x": 1070, "y": 200, "wires": [] }, - { - "id": "36cf43c754570ebd", - "type": "watch", - "z": "379c65a27117b46c", - "g": "b994fe21efb223a9", - "name": "", - "files": "config.json", - "recursive": "", - "x": 320, - "y": 140, - "wires": [ - [ - "32d8df5c0bb564cb" - ] - ] - }, { "id": "842ade29052f7e66", "type": "change", @@ -3099,7 +2971,7 @@ "from": "", "to": "", "reg": false, - "x": 1250, + "x": 850, "y": 200, "wires": [ [ @@ -3735,7 +3607,7 @@ "type": "global" } ], - "x": 1100, + "x": 700, "y": 140, "wires": [ [ @@ -3764,7 +3636,7 @@ "from": "", "to": "", "reg": false, - "x": 1230, + "x": 830, "y": 140, "wires": [ [ @@ -3816,7 +3688,7 @@ "type": "global" } ], - "x": 1110, + "x": 710, "y": 200, "wires": [ [ @@ -3841,6 +3713,26 @@ "icon": "font-awesome/fa-hand-stop-o", "l": true }, + { + "id": "2d4bed7c63632c6c", + "type": "template", + "z": "379c65a27117b46c", + "g": "b994fe21efb223a9", + "name": "General Config", + "field": "config", + "fieldType": "global", + "format": "json", + "syntax": "mustache", + "template": "{\n \"auth_method\": [ \"oauth\", \"token\" ],\n \"developer_mode\": false,\n \"html\": {\n \"logo\": \"http://nofusscomputing.com/assets/nfc_revamp_dark.png\",\n \"logo_width\": 282,\n \"logo_height\": 90\n },\n \"http_path\": \"/\",\n \"itsm\": {\n \"api_url\": \"http://glpi/apirest.php/\",\n \"create_ticket\": true,\n \"create_ticket_task\": true,\n \"platform\": \"glpi\",\n \"search\": true,\n \"human_task_duration_time\": 300,\n \"ticket\": {\n \"approval_required\": 0,\n \"category_id\": 6,\n \"entity_id\": 1,\n \"requesttype_id\": 6,\n \"task_category_id\": 2\n }\n },\n \"paths\": {\n \"user_data\": \"data/users/\",\n \"token_sessions\": \"data/sessions/\"\n }\n}\n", + "output": "json", + "x": 480, + "y": 100, + "wires": [ + [ + "06b5d27bbf1e5b16" + ] + ] + }, { "id": "02c4b9524d361ade", "type": "link in", @@ -4655,90 +4547,6 @@ ] ] }, - { - "id": "e36b580c48d33ca0", - "type": "template", - "z": "42b9663b67dbd983", - "g": "8a2206d682028469", - "name": "Content", - "field": "payload", - "fieldType": "msg", - "format": "json", - "syntax": "mustache", - "template": "{\n \"auth_method\": [ \"oauth\", \"token\" ],\n \"developer_mode\": false,\n \"html\": {\n \"logo\": \"http://nofusscomputing.com/assets/nfc_revamp_dark.png\",\n \"logo_width\": 282,\n \"logo_height\": 90\n },\n \"http_path\": \"/\",\n \"itsm\": {\n \"api_url\": \"http://glpi/apirest.php/\",\n \"create_ticket\": true,\n \"create_ticket_task\": true,\n \"platform\": \"glpi\",\n \"search\": true,\n \"human_task_duration_time\": 300,\n \"ticket\": {\n \"approval_required\": 0,\n \"category_id\": 6,\n \"entity_id\": 1,\n \"requesttype_id\": 6,\n \"task_category_id\": 2\n }\n },\n \"paths\": {\n \"user_data\": \"data/users/\",\n \"token_sessions\": \"data/sessions/\"\n }\n}\n", - "output": "json", - "x": 1580, - "y": 240, - "wires": [ - [ - "170b86b633c5ccd7" - ] - ] - }, - { - "id": "497a482f9881a318", - "type": "inject", - "z": "42b9663b67dbd983", - "g": "8a2206d682028469", - "name": "", - "props": [ - { - "p": "payload" - } - ], - "repeat": "", - "crontab": "", - "once": true, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 1430, - "y": 240, - "wires": [ - [ - "e36b580c48d33ca0" - ] - ] - }, - { - "id": "170b86b633c5ccd7", - "type": "file", - "z": "42b9663b67dbd983", - "g": "8a2206d682028469", - "name": "", - "filename": "config.json", - "filenameType": "str", - "appendNewline": true, - "createDir": false, - "overwriteFile": "true", - "encoding": "none", - "x": 1770, - "y": 240, - "wires": [ - [ - "befac3bb99b2c2cc" - ] - ] - }, - { - "id": "befac3bb99b2c2cc", - "type": "debug", - "z": "42b9663b67dbd983", - "g": "8a2206d682028469", - "name": "Config Written", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1940, - "y": 240, - "wires": [] - }, { "id": "9d93b8dfe83bf3ca", "type": "function",