From c27c12bb29a4cd3f6010bca237e9cf3d42f9dac9 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 13:00:31 +0930 Subject: [PATCH 01/10] feat(ui): add logout button !2 #2 --- flows.json | 318 +++++++++++++++++++++++++---------------------------- 1 file changed, 147 insertions(+), 171 deletions(-) diff --git a/flows.json b/flows.json index 11874bc..ababe69 100644 --- a/flows.json +++ b/flows.json @@ -81,7 +81,9 @@ "d460346f6ae1673b" ], "x": 154, - "y": 819 + "y": 819, + "w": 1912, + "h": 122 }, { "id": "ad0235dd3aa9eb7d", @@ -102,7 +104,9 @@ "317930c679e833d1" ], "x": 154, - "y": 679 + "y": 679, + "w": 1092, + "h": 82 }, { "id": "1c5c6c543ef047b6", @@ -121,7 +125,9 @@ "2f628eec7ca4b343" ], "x": 154, - "y": 299 + "y": 299, + "w": 812, + "h": 82 }, { "id": "a64f4a2c837d5c3c", @@ -143,7 +149,9 @@ "4ed718e1ae800bad" ], "x": 1314, - "y": 19 + "y": 19, + "w": 812, + "h": 127 }, { "id": "a8e6ecf8ae37659e", @@ -161,7 +169,9 @@ "6fc3fe2eef3733b0" ], "x": 154, - "y": 19 + "y": 19, + "w": 692, + "h": 82 }, { "id": "0abe2cea5975dcfd", @@ -180,7 +190,9 @@ "c9323e9dc74c9203" ], "x": 154, - "y": 419 + "y": 419, + "w": 812, + "h": 82 }, { "id": "07f2249ad4b7ccd0", @@ -199,7 +211,9 @@ "dcfa3cfba4eb1356" ], "x": 154, - "y": 539 + "y": 539, + "w": 812, + "h": 82 }, { "id": "d3393ec35cb20a93", @@ -217,7 +231,9 @@ "f1dcd5b6e32fb905" ], "x": 164, - "y": 139 + "y": 139, + "w": 462, + "h": 82 }, { "id": "3e330505ea1e9cba", @@ -235,7 +251,9 @@ "b664f0b9e6c17ad6" ], "x": 674, - "y": 139 + "y": 139, + "w": 492, + "h": 82 }, { "id": "b447a1f691eb02df", @@ -254,7 +272,9 @@ "b19bd0621d479d66" ], "x": 154, - "y": 999 + "y": 999, + "w": 812, + "h": 82 }, { "id": "0d96945ec7d069cb", @@ -272,9 +292,7 @@ "540882a95f65754c" ], "x": 114, - "y": 79, - "w": 972, - "h": 109.5 + "y": 79 }, { "id": "bcd2727d77a80ce3", @@ -292,9 +310,7 @@ "0f2ff2f433d17eef" ], "x": 114, - "y": 239, - "w": 912, - "h": 82 + "y": 239 }, { "id": "3b96ab15b1a54e33", @@ -343,9 +359,7 @@ "8e670403cf071aaf" ], "x": 114, - "y": 359, - "w": 1012, - "h": 122 + "y": 359 }, { "id": "9b1493c4ae19a935", @@ -366,8 +380,6 @@ ], "x": 94, "y": 639, - "w": 4744, - "h": 834, "info": "# Input Format\n\n``` json\n{\n \"data\": {\n // contains the data for the action\n },\n \"action\": \"search\",\n \"action_for\": \"user\"\n}\n```" }, { @@ -421,8 +433,6 @@ ], "x": 94, "y": 1527, - "w": 3012, - "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" }, { @@ -443,7 +453,9 @@ "befac3bb99b2c2cc" ], "x": 1314, - "y": 199 + "y": 199, + "w": 752, + "h": 82 }, { "id": "b994fe21efb223a9", @@ -596,9 +608,24 @@ "b595d8148f247f69" ], "x": 114, - "y": 519, - "w": 992, - "h": 82 + "y": 519 + }, + { + "id": "8f9d362a10096ca7", + "type": "group", + "z": "8179bf22c4c31682", + "style": { + "stroke": "#999999", + "stroke-opacity": "1", + "fill": "none", + "fill-opacity": "1", + "label": true, + "label-position": "nw", + "color": "#a4a4a4" + }, + "nodes": [], + "x": 0, + "y": 0 }, { "id": "aea0a3398dafab4c", @@ -638,9 +665,7 @@ "d7dbd3970c891c33" ], "x": 234, - "y": 813, - "w": 4578, - "h": 634 + "y": 813 }, { "id": "82ccba0e0a13970a", @@ -1098,9 +1123,7 @@ "bcaed4334222c14a" ], "x": 508, - "y": 1553, - "w": 1204, - "h": 234 + "y": 1553 }, { "id": "cc33365c2aa59e35", @@ -1121,9 +1144,7 @@ "5851acefa1f1b5ff" ], "x": 514, - "y": 1813, - "w": 2072, - "h": 334 + "y": 1813 }, { "id": "7225c45ad941c14f", @@ -1152,8 +1173,6 @@ ], "x": 514, "y": 2193, - "w": 2078, - "h": 394, "info": "# Oauth2 Authentication\n\n" }, { @@ -1186,9 +1205,7 @@ "e2cbcdcc69e9ce21" ], "x": 234, - "y": 2639, - "w": 2352, - "h": 182 + "y": 2639 }, { "id": "ed0645c12f7435b2", @@ -1221,9 +1238,7 @@ "5a961504d7ca5be3" ], "x": 754, - "y": 1051.5, - "w": 4032, - "h": 369.5 + "y": 1051.5 }, { "id": "d7dbd3970c891c33", @@ -1248,9 +1263,7 @@ "a888a2ed9a053acc" ], "x": 754, - "y": 839, - "w": 1412, - "h": 182 + "y": 839 }, { "id": "75c44e5f7f101beb", @@ -1270,9 +1283,7 @@ "95f44fbb0ddd39fc" ], "x": 754, - "y": 1839, - "w": 672, - "h": 122 + "y": 1839 }, { "id": "bcaed4334222c14a", @@ -1299,8 +1310,6 @@ ], "x": 534, "y": 1579, - "w": 1152, - "h": 182, "info": "# Cookie Validation\n\nThis path is always executed and is the first step in the authentication workflow. \n\nThis groups workflow is as follows:\n\n1. fetch the value of `msg.req.cookies.auth`\n\n * if empty/null. User needs to logon\n\n * value found, goto step 2\n\n2. open the session file using the value of `msg.req.cookies.auth`\n\n3. set `msg.session` with the contents of the file\n\n4. Route for further validation based off of type `oauth2` or `token`.\n\nthe existance of path `msg.req.cookies.auth` alludes to a user that has authenticated previously. \nWhilst this value could be guessed, it is highly unlikely.\n" }, { @@ -1324,9 +1333,7 @@ "444cde06405f24e3" ], "x": 1034, - "y": 2439, - "w": 972, - "h": 122 + "y": 2439 }, { "id": "f5e65e1ae7e8b812", @@ -1354,119 +1361,7 @@ "54e638b390e13c61" ], "x": 1034, - "y": 2219, - "w": 1532, - "h": 202 - }, - { - "id": "85fa24886e126df7", - "type": "group", - "z": "8179bf22c4c31682", - "g": "ed0645c12f7435b2", - "name": "Ticket Solution", - "style": { - "stroke": "#6f2fa0", - "fill": "#bfdbef", - "label": true - }, - "nodes": [ - "40208ed719417cac", - "803a8b65fc7a5087", - "96766518a046855d", - "242b471ad711a4f1", - "1305e2f195ec5ede", - "285f57c0fee687a1" - ], - "x": 2234, - "y": 1259, - "w": 1472, - "h": 82 - }, - { - "id": "aa5626527a9df701", - "type": "group", - "z": "8179bf22c4c31682", - "g": "ed0645c12f7435b2", - "name": "Ticket Task", - "style": { - "stroke": "#6f2fa0", - "fill": "#bfdbef", - "label": true - }, - "nodes": [ - "351440700b3e2ecc", - "f17ccfa845461657" - ], - "x": 2228, - "y": 1093, - "w": 2204, - "h": 134 - }, - { - "id": "351440700b3e2ecc", - "type": "group", - "z": "8179bf22c4c31682", - "g": "aa5626527a9df701", - "name": "Create", - "style": { - "stroke": "#001f60", - "fill": "#e3f3d3", - "label": true, - "color": "#777777" - }, - "nodes": [ - "fb6750555645b873", - "e0660324da4581dd" - ], - "x": 2254, - "y": 1119, - "w": 492, - "h": 82 - }, - { - "id": "f17ccfa845461657", - "type": "group", - "z": "8179bf22c4c31682", - "g": "aa5626527a9df701", - "name": "Update", - "style": { - "stroke": "#001f60", - "fill": "#e3f3d3", - "label": true, - "color": "#777777" - }, - "nodes": [ - "eacbafc05d06b95a", - "76cd564b69443419", - "ca1b9c48c3c0c522", - "d64e9c631ee7ec87", - "cafa50da13d9e5d9", - "c2f8e99492223cfb", - "fdf014eff1962329" - ], - "x": 2794, - "y": 1119, - "w": 1612, - "h": 82 - }, - { - "id": "8f9d362a10096ca7", - "type": "group", - "z": "8179bf22c4c31682", - "style": { - "stroke": "#999999", - "stroke-opacity": "1", - "fill": "none", - "fill-opacity": "1", - "label": true, - "label-position": "nw", - "color": "#a4a4a4" - }, - "nodes": [], - "x": null, - "y": null, - "w": 40, - "h": 40 + "y": 2219 }, { "id": "5851acefa1f1b5ff", @@ -1494,10 +1389,91 @@ ], "x": 754, "y": 1999, - "w": 1302, - "h": 122, "info": "# Token Generate\n\nThis sub-group contains the nodes required to generate an authentication token.\n\nThere are two entrypoints for this group:\n\n1. _(Development)_ Click on the generate token to create one for a abritary user\n\n1. `Token: Generate` Link-In node. This is used for other flows which may require a token to be generated for a user. Details must be provided.\n\nThe latter is useful if you create a user with a random password and they need a method to be able to reset it.\n\n## Input Data\n\nthis node requires an object at path `msg.auth.user`.\n\n``` json\n\nmsg.auth.user = {\n \"username\": \"barny.gumble\",\n \"fname\": \"Barny\",\n \"lname\": \"Gumble\",\n \"mail\": \"barney.gumble@dinomail.com\"\n };\n\n```\n\n**NOTE:** _Missing any of the `json` attributes will prevent the user from resetting their password as all of these fields are required._\n" }, + { + "id": "85fa24886e126df7", + "type": "group", + "z": "8179bf22c4c31682", + "g": "ed0645c12f7435b2", + "name": "Ticket Solution", + "style": { + "stroke": "#6f2fa0", + "fill": "#bfdbef", + "label": true + }, + "nodes": [ + "40208ed719417cac", + "803a8b65fc7a5087", + "96766518a046855d", + "242b471ad711a4f1", + "1305e2f195ec5ede", + "285f57c0fee687a1" + ], + "x": 2234, + "y": 1259 + }, + { + "id": "aa5626527a9df701", + "type": "group", + "z": "8179bf22c4c31682", + "g": "ed0645c12f7435b2", + "name": "Ticket Task", + "style": { + "stroke": "#6f2fa0", + "fill": "#bfdbef", + "label": true + }, + "nodes": [ + "351440700b3e2ecc", + "f17ccfa845461657" + ], + "x": 2228, + "y": 1093 + }, + { + "id": "351440700b3e2ecc", + "type": "group", + "z": "8179bf22c4c31682", + "g": "aa5626527a9df701", + "name": "Create", + "style": { + "stroke": "#001f60", + "fill": "#e3f3d3", + "label": true, + "color": "#777777" + }, + "nodes": [ + "fb6750555645b873", + "e0660324da4581dd" + ], + "x": 2254, + "y": 1119 + }, + { + "id": "f17ccfa845461657", + "type": "group", + "z": "8179bf22c4c31682", + "g": "aa5626527a9df701", + "name": "Update", + "style": { + "stroke": "#001f60", + "fill": "#e3f3d3", + "label": true, + "color": "#777777" + }, + "nodes": [ + "eacbafc05d06b95a", + "76cd564b69443419", + "ca1b9c48c3c0c522", + "d64e9c631ee7ec87", + "cafa50da13d9e5d9", + "c2f8e99492223cfb", + "fdf014eff1962329" + ], + "x": 2794, + "y": 1119 + }, { "id": "5798e39cbc3730ae", "type": "junction", @@ -4065,7 +4041,7 @@ "fieldType": "msg", "format": "handlebars", "syntax": "mustache", - "template": "
\n

Main Menu

\n\n

G'Day {{{ session.user.fname}}}

\n\n \n \n \n{{#global.config.developer_mode}}\n \n \n{{/global.config.developer_mode}}\n\n
", + "template": "
\n

Main Menu

\n\n

G'Day {{{ session.user.fname}}}

\n\n \n \n \n{{#global.config.developer_mode}}\n \n{{/global.config.developer_mode}}\n \n\n
", "x": 450, "y": 340, "wires": [ -- 2.49.0 From 65a370b8100d6579f451c097bf5633b8332b01dd Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 13:17:54 +0930 Subject: [PATCH 02/10] fix(cron): auto load delay set to 5 seconds this is required so that the config can load as cron requires the config !2 --- flows.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flows.json b/flows.json index ababe69..c307e8d 100644 --- a/flows.json +++ b/flows.json @@ -14293,7 +14293,7 @@ "repeat": "60", "crontab": "", "once": true, - "onceDelay": 0.1, + "onceDelay": "5", "topic": "", "x": 180, "y": 160, -- 2.49.0 From e6d4386848966d2afae0d8280fbb39af02dda9a7 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 13:40:49 +0930 Subject: [PATCH 03/10] feat(logout): remove cookie and delete session. Dont build html as they subsequent requests will cause a logon. !2 closes #2 --- flows.json | 89 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/flows.json b/flows.json index c307e8d..685a304 100644 --- a/flows.json +++ b/flows.json @@ -267,13 +267,13 @@ }, "nodes": [ "fb5301abffede979", - "1102d30391c745a6", "988765ea19236af0", - "b19bd0621d479d66" + "abcdd1bd3d9d1892", + "c17fe14224b2a367" ], "x": 154, "y": 999, - "w": 812, + "w": 752, "h": 82 }, { @@ -4365,31 +4365,12 @@ "y": 1040, "wires": [ [ - "1102d30391c745a6" + "abcdd1bd3d9d1892" ] ], "icon": "node-red/file.svg", "l": true }, - { - "id": "1102d30391c745a6", - "type": "template", - "z": "42b9663b67dbd983", - "g": "b447a1f691eb02df", - "name": "HTML", - "field": "html.body", - "fieldType": "msg", - "format": "handlebars", - "syntax": "mustache", - "template": "logout", - "x": 470, - "y": 1040, - "wires": [ - [ - "b19bd0621d479d66" - ] - ] - }, { "id": "988765ea19236af0", "type": "link out", @@ -4400,30 +4381,11 @@ "links": [ "7db929503cf13635" ], - "x": 850, + "x": 790, "y": 1040, "wires": [], "l": true }, - { - "id": "b19bd0621d479d66", - "type": "link call", - "z": "42b9663b67dbd983", - "g": "b447a1f691eb02df", - "name": "Build HTML", - "links": [ - "3ec10e706b7bdc9d" - ], - "linkType": "static", - "timeout": "30", - "x": 630, - "y": 1040, - "wires": [ - [ - "988765ea19236af0" - ] - ] - }, { "id": "52dc13e1fdbf064d", "type": "file in", @@ -4691,6 +4653,47 @@ ], "icon": "font-awesome/fa-question" }, + { + "id": "abcdd1bd3d9d1892", + "type": "function", + "z": "42b9663b67dbd983", + "g": "b447a1f691eb02df", + "name": "Clear Session", + "func": "\nmsg.payload = \"Logged Out\"\n\nmsg.filename = msg.req.cookies.auth + '.json';\n\nmsg.cookies = {\n\n \"auth\": {\n maxAge: 1000\n }\n\n};\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 420, + "y": 1040, + "wires": [ + [ + "c17fe14224b2a367" + ] + ], + "info": "# Clear Session\n\nThis node is responsible for ensuring the cookie is expired." + }, + { + "id": "c17fe14224b2a367", + "type": "fs-remove", + "z": "42b9663b67dbd983", + "g": "b447a1f691eb02df", + "path": "config.paths.token_sessions", + "pathType": "global", + "filename": "filename", + "filenameType": "msg", + "recursive": false, + "exist": true, + "name": "Remove Token", + "x": 600, + "y": 1040, + "wires": [ + [ + "988765ea19236af0" + ] + ] + }, { "id": "bb8102ee0c070ff2", "type": "link in", -- 2.49.0 From df98fc4a85c96c3471d5729783bce971d5c469c0 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:06:32 +0930 Subject: [PATCH 04/10] fix(auth): start auth at beginning not cookie check !2 --- flows.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flows.json b/flows.json index 685a304..d1ea61c 100644 --- a/flows.json +++ b/flows.json @@ -3279,7 +3279,7 @@ "g": "923268ee62c6a7db", "name": "Authentication", "links": [ - "33f25da80ef87e72" + "f17afdbfc8c07889" ], "linkType": "static", "timeout": "30", -- 2.49.0 From 0318c478feb8c3319c3ca35821d609bb436c4302 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:08:55 +0930 Subject: [PATCH 05/10] fix(logout): dont error if file absent !2 #2 --- flows.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flows.json b/flows.json index d1ea61c..e5ad780 100644 --- a/flows.json +++ b/flows.json @@ -4684,7 +4684,7 @@ "filename": "filename", "filenameType": "msg", "recursive": false, - "exist": true, + "exist": false, "name": "Remove Token", "x": 600, "y": 1040, -- 2.49.0 From 12b528d2f103c583664a8f3a17cb395eae6d01a0 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:11:52 +0930 Subject: [PATCH 06/10] feat(auth): add logout path check this will cause the auth path to switch to logging the user out !2 #2 --- flows.json | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/flows.json b/flows.json index e5ad780..5643922 100644 --- a/flows.json +++ b/flows.json @@ -429,10 +429,15 @@ "724a142f28c3b6e4", "f9550cdd015b52ae", "cc33365c2aa59e35", - "69f0d6271fe16536" + "69f0d6271fe16536", + "1552576e6e79e172", + "3fa2f7ecc012d8c6", + "a67892bd64d2ded4" ], "x": 94, "y": 1527, + "w": 3012, + "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" }, { @@ -2131,6 +2136,19 @@ ] ] }, + { + "id": "a67892bd64d2ded4", + "type": "junction", + "z": "8179bf22c4c31682", + "g": "bbd929c437c592ea", + "x": 500, + "y": 1620, + "wires": [ + [ + "3fa2f7ecc012d8c6" + ] + ] + }, { "id": "160d0b5ed597dc51", "type": "ldap", @@ -7142,10 +7160,10 @@ "name": "Authentication Begin", "links": [], "x": 210, - "y": 1580, + "y": 1600, "wires": [ [ - "f9550cdd015b52ae" + "1552576e6e79e172" ] ], "icon": "node-red/arrow-in.svg", @@ -9452,6 +9470,50 @@ "wires": [], "l": true }, + { + "id": "1552576e6e79e172", + "type": "function", + "z": "8179bf22c4c31682", + "g": "bbd929c437c592ea", + "name": "Logout check", + "func": "var authenticate = msg;\nvar logout = null;\n\nvar status = {fill:\"red\",shape:\"ring\",text:\"Err: Incomplete\"};\n\nif (msg.req._parsedUrl.path == '/logout' ){\n\n msg.session = {};\n status.fill = 'green';\n status.text = 'logout';\n\n authenticate = null;\n logout = msg;\n\n}else{\n status.fill = 'blue';\n status.text = 'authenticate';\n}\n\nnode.status( status );\n\nnode.send([\n authenticate,\n logout\n]);", + "outputs": 2, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 390, + "y": 1600, + "wires": [ + [ + "f9550cdd015b52ae" + ], + [ + "a67892bd64d2ded4" + ] + ], + "outputLabels": [ + "Authenticate", + "Logout" + ], + "icon": "font-awesome/fa-question" + }, + { + "id": "3fa2f7ecc012d8c6", + "type": "link out", + "z": "8179bf22c4c31682", + "g": "bbd929c437c592ea", + "name": "Logout", + "mode": "link", + "links": [ + "e80aabc47c664088" + ], + "x": 610, + "y": 1620, + "wires": [], + "icon": "font-awesome/fa-sign-out", + "l": true + }, { "id": "17f893c2bb347668", "type": "inject", -- 2.49.0 From f2e0b5c9ba7bd88c724010f158b886b6f4cecf91 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:14:56 +0930 Subject: [PATCH 07/10] refactor(random): NodeRED changes that are not changes !2 --- flows.json | 258 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 167 insertions(+), 91 deletions(-) diff --git a/flows.json b/flows.json index 5643922..9c6c9ec 100644 --- a/flows.json +++ b/flows.json @@ -292,7 +292,9 @@ "540882a95f65754c" ], "x": 114, - "y": 79 + "y": 79, + "w": 972, + "h": 109.5 }, { "id": "bcd2727d77a80ce3", @@ -310,7 +312,9 @@ "0f2ff2f433d17eef" ], "x": 114, - "y": 239 + "y": 239, + "w": 912, + "h": 82 }, { "id": "3b96ab15b1a54e33", @@ -341,7 +345,9 @@ "05accf0d9a6f0aa8" ], "x": 134, - "y": 119 + "y": 119, + "w": 2312, + "h": 182 }, { "id": "10a6c6b12749dda9", @@ -359,7 +365,9 @@ "8e670403cf071aaf" ], "x": 114, - "y": 359 + "y": 359, + "w": 1012, + "h": 122 }, { "id": "9b1493c4ae19a935", @@ -380,6 +388,8 @@ ], "x": 94, "y": 639, + "w": 4744, + "h": 834, "info": "# Input Format\n\n``` json\n{\n \"data\": {\n // contains the data for the action\n },\n \"action\": \"search\",\n \"action_for\": \"user\"\n}\n```" }, { @@ -405,6 +415,8 @@ ], "x": 128, "y": 333, + "w": 2798, + "h": 774, "info": "# Password Reset Form Processing\n\nThis group is responsible for processing the data from the password reset form. the basic workflow is as follows:\n\n- Form validation\n\n- LDAP User Search\n\n- ITSM User Search: if enabled searches for user within itsm system\n\n- ITSM Ticket: if enabled, creates ticket within ITSM system\n\n- Response: User notification\n" }, { @@ -514,6 +526,8 @@ ], "x": 128, "y": 1133, + "w": 4704, + "h": 228, "info": "# Change User Password\n\nThis group contains the workflow to change a users password within LDAP.\n\nThe workflow has th following steps:\n\n1. Validate the form input\n\n1. Check that the new password fields match\n\n1. Confirm that the user entered \"Current Password\" matches what's in LDAP\n\n1. Change the users password within LDAP.\n" }, { @@ -566,7 +580,9 @@ "2bcdbb78b4e9181f" ], "x": 54, - "y": 99 + "y": 99, + "w": 1192, + "h": 282 }, { "id": "f7c0a5bee0e0df33", @@ -594,7 +610,9 @@ "291408859782056d" ], "x": 1274, - "y": 99 + "y": 99, + "w": 1872, + "h": 142 }, { "id": "e8558844b3710e7b", @@ -613,7 +631,9 @@ "b595d8148f247f69" ], "x": 114, - "y": 519 + "y": 519, + "w": 992, + "h": 82 }, { "id": "8f9d362a10096ca7", @@ -630,7 +650,9 @@ }, "nodes": [], "x": 0, - "y": 0 + "y": 0, + "w": 40, + "h": 40 }, { "id": "aea0a3398dafab4c", @@ -649,7 +671,9 @@ "8eca6e69b809790c" ], "x": 2214, - "y": 999 + "y": 999, + "w": 512, + "h": 82 }, { "id": "9858d84dc9d001be", @@ -670,7 +694,9 @@ "d7dbd3970c891c33" ], "x": 234, - "y": 813 + "y": 813, + "w": 4578, + "h": 634 }, { "id": "82ccba0e0a13970a", @@ -688,7 +714,9 @@ "f125e4c474dd2e5c" ], "x": 2214, - "y": 899 + "y": 899, + "w": 512, + "h": 82 }, { "id": "d0dc259791aed430", @@ -711,7 +739,9 @@ "13711f1826f83198" ], "x": 574, - "y": 959 + "y": 959, + "w": 1432, + "h": 122 }, { "id": "d1b4f7ad9e8ea4f0", @@ -733,7 +763,9 @@ "1a29880acc851ff5" ], "x": 834, - "y": 819 + "y": 819, + "w": 912, + "h": 122 }, { "id": "4cdebccc4a1f08ed", @@ -759,7 +791,9 @@ "5cfc1e5277013397" ], "x": 434, - "y": 519 + "y": 519, + "w": 1752, + "h": 122 }, { "id": "9926c0ba3f91aca8", @@ -785,7 +819,9 @@ "f6fc2010d0af1e33" ], "x": 574, - "y": 659 + "y": 659, + "w": 1452, + "h": 142 }, { "id": "f8ec4a6290dc7e20", @@ -808,7 +844,9 @@ "815ce9e0380e642f" ], "x": 1074, - "y": 1159 + "y": 1159, + "w": 1072, + "h": 122 }, { "id": "cf2a3f84cb26a12c", @@ -1039,6 +1077,8 @@ ], "x": 154, "y": 359, + "w": 972, + "h": 142, "info": "# Password Reset Form Processing\n\nThis sub-group is the fist step in processing the password reset form.\n\nfor the form workflow to continue processing the form, the form user details entered, must match the authenticated users details. The details **must** match, as without this matching and by design this form can reset the password of any user where the details are correcct." }, { @@ -1061,6 +1101,8 @@ ], "x": 154, "y": 1159, + "w": 812, + "h": 122, "info": "# Form Validation\n\nValidate the password change form." }, { @@ -1085,6 +1127,8 @@ ], "x": 2214, "y": 1159, + "w": 1152, + "h": 122, "info": "# Check Current Password\n\nConfirm that the user entered \"current password\" matches the LDAP value" }, { @@ -1110,6 +1154,8 @@ ], "x": 3394, "y": 1159, + "w": 1412, + "h": 122, "info": "# Change User Password\n\nChange the users password within LDAP" }, { @@ -1127,8 +1173,10 @@ "nodes": [ "bcaed4334222c14a" ], - "x": 508, - "y": 1553 + "x": 768, + "y": 1553, + "w": 1204, + "h": 234 }, { "id": "cc33365c2aa59e35", @@ -1148,8 +1196,10 @@ "a4bc5830daf9801a", "5851acefa1f1b5ff" ], - "x": 514, - "y": 1813 + "x": 774, + "y": 1813, + "w": 2072, + "h": 334 }, { "id": "7225c45ad941c14f", @@ -1176,8 +1226,10 @@ "261436c730a46051", "97fb6e1471c0f7cd" ], - "x": 514, + "x": 774, "y": 2193, + "w": 2078, + "h": 394, "info": "# Oauth2 Authentication\n\n" }, { @@ -1210,7 +1262,9 @@ "e2cbcdcc69e9ce21" ], "x": 234, - "y": 2639 + "y": 2639, + "w": 2352, + "h": 182 }, { "id": "ed0645c12f7435b2", @@ -1243,7 +1297,9 @@ "5a961504d7ca5be3" ], "x": 754, - "y": 1051.5 + "y": 1051.5, + "w": 4032, + "h": 369.5 }, { "id": "d7dbd3970c891c33", @@ -1268,7 +1324,9 @@ "a888a2ed9a053acc" ], "x": 754, - "y": 839 + "y": 839, + "w": 1412, + "h": 182 }, { "id": "75c44e5f7f101beb", @@ -1287,8 +1345,10 @@ "8b1fef39c34f5513", "95f44fbb0ddd39fc" ], - "x": 754, - "y": 1839 + "x": 1014, + "y": 1839, + "w": 672, + "h": 122 }, { "id": "bcaed4334222c14a", @@ -1313,8 +1373,10 @@ "9cbf4beaceba5255", "da0811fbd7963934" ], - "x": 534, + "x": 794, "y": 1579, + "w": 1152, + "h": 182, "info": "# Cookie Validation\n\nThis path is always executed and is the first step in the authentication workflow. \n\nThis groups workflow is as follows:\n\n1. fetch the value of `msg.req.cookies.auth`\n\n * if empty/null. User needs to logon\n\n * value found, goto step 2\n\n2. open the session file using the value of `msg.req.cookies.auth`\n\n3. set `msg.session` with the contents of the file\n\n4. Route for further validation based off of type `oauth2` or `token`.\n\nthe existance of path `msg.req.cookies.auth` alludes to a user that has authenticated previously. \nWhilst this value could be guessed, it is highly unlikely.\n" }, { @@ -1337,8 +1399,10 @@ "a49db4bcea29097d", "444cde06405f24e3" ], - "x": 1034, - "y": 2439 + "x": 1294, + "y": 2439, + "w": 972, + "h": 122 }, { "id": "f5e65e1ae7e8b812", @@ -1365,8 +1429,10 @@ "36c7736ada06ef15", "54e638b390e13c61" ], - "x": 1034, - "y": 2219 + "x": 1294, + "y": 2219, + "w": 1532, + "h": 202 }, { "id": "5851acefa1f1b5ff", @@ -1392,8 +1458,10 @@ "1dc714dfeaa9a42d", "a68c08dfd9ce3d8c" ], - "x": 754, + "x": 1014, "y": 1999, + "w": 1302, + "h": 122, "info": "# Token Generate\n\nThis sub-group contains the nodes required to generate an authentication token.\n\nThere are two entrypoints for this group:\n\n1. _(Development)_ Click on the generate token to create one for a abritary user\n\n1. `Token: Generate` Link-In node. This is used for other flows which may require a token to be generated for a user. Details must be provided.\n\nThe latter is useful if you create a user with a random password and they need a method to be able to reset it.\n\n## Input Data\n\nthis node requires an object at path `msg.auth.user`.\n\n``` json\n\nmsg.auth.user = {\n \"username\": \"barny.gumble\",\n \"fname\": \"Barny\",\n \"lname\": \"Gumble\",\n \"mail\": \"barney.gumble@dinomail.com\"\n };\n\n```\n\n**NOTE:** _Missing any of the `json` attributes will prevent the user from resetting their password as all of these fields are required._\n" }, { @@ -1416,7 +1484,9 @@ "285f57c0fee687a1" ], "x": 2234, - "y": 1259 + "y": 1259, + "w": 1472, + "h": 82 }, { "id": "aa5626527a9df701", @@ -1434,7 +1504,9 @@ "f17ccfa845461657" ], "x": 2228, - "y": 1093 + "y": 1093, + "w": 2204, + "h": 134 }, { "id": "351440700b3e2ecc", @@ -1453,7 +1525,9 @@ "e0660324da4581dd" ], "x": 2254, - "y": 1119 + "y": 1119, + "w": 492, + "h": 82 }, { "id": "f17ccfa845461657", @@ -1477,7 +1551,9 @@ "fdf014eff1962329" ], "x": 2794, - "y": 1119 + "y": 1119, + "w": 1612, + "h": 82 }, { "id": "5798e39cbc3730ae", @@ -7235,7 +7311,7 @@ "627a72eee1e26ae6", "b174f7bc1d398a56" ], - "x": 610, + "x": 870, "y": 2240, "wires": [ [ @@ -7942,7 +8018,7 @@ "20aae4d90a07f156", "54e638b390e13c61" ], - "x": 1570, + "x": 1830, "y": 1620, "wires": [], "icon": "node-red/arrow-in.svg", @@ -7962,7 +8038,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1370, + "x": 1630, "y": 1700, "wires": [] }, @@ -7978,7 +8054,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1380, + "x": 1640, "y": 1640, "wires": [ [ @@ -8008,7 +8084,7 @@ "sendError": false, "encoding": "none", "allProps": false, - "x": 1180, + "x": 1440, "y": 1640, "wires": [ [ @@ -8027,7 +8103,7 @@ "links": [ "e80aabc47c664088" ], - "x": 1170, + "x": 1430, "y": 1680, "wires": [], "icon": "font-awesome/fa-lock", @@ -8048,7 +8124,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1150, + "x": 1410, "y": 1720, "wires": [] }, @@ -8069,7 +8145,7 @@ "module": "fs" } ], - "x": 910, + "x": 1170, "y": 1660, "wires": [ [ @@ -8094,10 +8170,9 @@ "g": "bcaed4334222c14a", "name": "Cookie: Begin Validation", "links": [ - "5c30dbcce4f3e71e", "f9550cdd015b52ae" ], - "x": 670, + "x": 930, "y": 1660, "wires": [ [ @@ -8117,7 +8192,7 @@ "links": [ "8b1fef39c34f5513" ], - "x": 1560, + "x": 1820, "y": 1660, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8134,7 +8209,7 @@ "9c55bf6229fa740c", "95f44fbb0ddd39fc" ], - "x": 2330, + "x": 2590, "y": 2100, "wires": [ [ @@ -8154,7 +8229,7 @@ "links": [ "e80aabc47c664088" ], - "x": 2480, + "x": 2740, "y": 2100, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8170,7 +8245,7 @@ "links": [ "c10e09e4bfbddfd7" ], - "x": 1290, + "x": 1550, "y": 1920, "wires": [], "icon": "font-awesome/fa-refresh", @@ -8193,7 +8268,7 @@ "module": "fs" } ], - "x": 1070, + "x": 1330, "y": 1900, "wires": [ [ @@ -8217,7 +8292,7 @@ "links": [ "da0811fbd7963934" ], - "x": 860, + "x": 1120, "y": 1900, "wires": [ [ @@ -8237,7 +8312,7 @@ "links": [ "c10e09e4bfbddfd7" ], - "x": 1300, + "x": 1560, "y": 1880, "wires": [], "icon": "font-awesome/fa-unlock", @@ -8254,7 +8329,8 @@ "9c05ca2751f619a7", "8ad6190854001584", "413dbeb6f2d0d2d0", - "d24ebda198149601" + "d24ebda198149601", + "3fa2f7ecc012d8c6" ], "x": 2870, "y": 2820, @@ -8289,7 +8365,7 @@ "links": [ "33f25da80ef87e72" ], - "x": 380, + "x": 580, "y": 1580, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8302,7 +8378,7 @@ "g": "cc33365c2aa59e35", "name": "Token: Begin", "links": [], - "x": 610, + "x": 870, "y": 1860, "wires": [ [] @@ -8322,7 +8398,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 750, + "x": 1010, "y": 2240, "wires": [ [ @@ -8350,7 +8426,7 @@ "de76019e24c52ae0", "9d0d1d9a6c596428" ], - "x": 920, + "x": 1180, "y": 2240, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8366,7 +8442,7 @@ "links": [ "21ec376b58ac0c54" ], - "x": 910, + "x": 1170, "y": 2280, "wires": [], "icon": "font-awesome/fa-exclamation-triangle", @@ -8383,7 +8459,7 @@ "8964a5bda9eb7113", "a30dab395f333826" ], - "x": 2240, + "x": 2500, "y": 2540, "wires": [ [ @@ -8403,7 +8479,7 @@ "links": [ "e80aabc47c664088" ], - "x": 2460, + "x": 2720, "y": 2540, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8418,7 +8494,7 @@ "links": [ "9cbf4beaceba5255" ], - "x": 1190, + "x": 1450, "y": 2320, "wires": [ [ @@ -8440,7 +8516,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1440, + "x": 1700, "y": 2320, "wires": [ [ @@ -8472,7 +8548,7 @@ "links": [ "21ec376b58ac0c54" ], - "x": 1640, + "x": 1900, "y": 2300, "wires": [], "icon": "font-awesome/fa-unlock", @@ -8489,7 +8565,7 @@ "links": [ "21ec376b58ac0c54" ], - "x": 1650, + "x": 1910, "y": 2340, "wires": [], "icon": "font-awesome/fa-lock", @@ -8510,7 +8586,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1630, + "x": 1890, "y": 2380, "wires": [] }, @@ -8528,7 +8604,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1890, + "x": 2150, "y": 2280, "wires": [] }, @@ -8544,7 +8620,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1920, + "x": 2180, "y": 2320, "wires": [ [ @@ -8569,7 +8645,7 @@ "authType": "", "senderr": false, "headers": [], - "x": 2100, + "x": 2360, "y": 2320, "wires": [ [ @@ -8598,7 +8674,7 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 2230, + "x": 2490, "y": 2320, "wires": [ [ @@ -8624,7 +8700,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 2380, + "x": 2640, "y": 2260, "wires": [] }, @@ -8638,7 +8714,7 @@ "links": [ "97fb6e1471c0f7cd" ], - "x": 2430, + "x": 2690, "y": 2300, "wires": [], "icon": "node-red/arrow-in.svg", @@ -8658,7 +8734,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 2390, + "x": 2650, "y": 2360, "wires": [] }, @@ -8873,7 +8949,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1890, + "x": 2150, "y": 2520, "wires": [] }, @@ -8886,7 +8962,7 @@ "links": [ "60a97c78327c3a6a" ], - "x": 1160, + "x": 1420, "y": 2520, "wires": [ [ @@ -8908,7 +8984,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1350, + "x": 1610, "y": 2520, "wires": [ [ @@ -8934,7 +9010,7 @@ "authType": "", "senderr": false, "headers": [], - "x": 1540, + "x": 1800, "y": 2520, "wires": [ [ @@ -8954,7 +9030,7 @@ "links": [ "97fb6e1471c0f7cd" ], - "x": 1720, + "x": 1980, "y": 2520, "wires": [], "icon": "font-awesome/fa-unlock", @@ -8967,7 +9043,7 @@ "g": "9f3711f96411e2cc", "name": "ToDo", "info": "check for http 400, and return error on screen", - "x": 1730, + "x": 1990, "y": 2480, "wires": [] }, @@ -9253,7 +9329,7 @@ "8b072412d6eea267", "e6f37f07e9217707" ], - "x": 2240, + "x": 2500, "y": 2480, "wires": [ [ @@ -9273,7 +9349,7 @@ "links": [ "150344ba8db2ceee" ], - "x": 2430, + "x": 2690, "y": 2480, "wires": [], "icon": "node-red/arrow-in.svg", @@ -9302,7 +9378,7 @@ "once": false, "onceDelay": 0.1, "topic": "", - "x": 890, + "x": 1150, "y": 2040, "wires": [ [ @@ -9322,7 +9398,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1370, + "x": 1630, "y": 2080, "wires": [ [ @@ -9341,7 +9417,7 @@ ], "linkType": "static", "timeout": "30", - "x": 1530, + "x": 1790, "y": 2080, "wires": [ [ @@ -9361,7 +9437,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1650, + "x": 1910, "y": 2080, "wires": [ [ @@ -9381,7 +9457,7 @@ "createDir": true, "overwriteFile": "true", "encoding": "none", - "x": 1760, + "x": 2020, "y": 2080, "wires": [ [ @@ -9404,7 +9480,7 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 1930, + "x": 2190, "y": 2040, "wires": [] }, @@ -9420,7 +9496,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1120, + "x": 1380, "y": 2040, "wires": [ [ @@ -9435,7 +9511,7 @@ "g": "5851acefa1f1b5ff", "name": "ToDo: add random salt to hash generation", "info": "", - "x": 1460, + "x": 1720, "y": 2040, "wires": [] }, @@ -9448,7 +9524,7 @@ "links": [], "linkType": "static", "timeout": "30", - "x": 870, + "x": 1130, "y": 2080, "wires": [ [ @@ -9465,7 +9541,7 @@ "name": "Return", "mode": "return", "links": [], - "x": 1980, + "x": 2240, "y": 2080, "wires": [], "l": true -- 2.49.0 From 1d974579d6f2032bb72f3fe5c51462020b0e28a3 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:20:55 +0930 Subject: [PATCH 08/10] docs(logout): add NodeRed group docs !2 #2 --- flows.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flows.json b/flows.json index 9c6c9ec..dd4f055 100644 --- a/flows.json +++ b/flows.json @@ -274,7 +274,8 @@ "x": 154, "y": 999, "w": 752, - "h": 82 + "h": 82, + "info": "# Logout\n\nThis group contains the `/logout` path.\nAs part of this groups glow, when navigated to. \nThe users cookie is set to expire and the user session is removed from the filesystem." }, { "id": "0d96945ec7d069cb", -- 2.49.0 From 79020408d1cc56dde0ce38a0fd9b1cae1f76151e Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:22:38 +0930 Subject: [PATCH 09/10] build: adjust ver to pre-release 0 !2 --- .cz.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cz.yaml b/.cz.yaml index 62b2ada..e260c98 100644 --- a/.cz.yaml +++ b/.cz.yaml @@ -4,4 +4,4 @@ commitizen: name: cz_conventional_commits tag_format: $major.$minor.$patch$prerelease update_changelog_on_bump: true - version: 0.0.1 + version: 1.0.0rc0 -- 2.49.0 From 8fb49a4834f8e3d944a3db421a369a559d695add Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 15 Aug 2023 14:33:26 +0930 Subject: [PATCH 10/10] fix(logout): prevent favicon.ico from triggering logon !2 #2 --- flows.json | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/flows.json b/flows.json index dd4f055..23120d1 100644 --- a/flows.json +++ b/flows.json @@ -870,11 +870,12 @@ "adbfd4257ea1c230", "c6360f6028e1512c", "b174f7bc1d398a56", - "3dc07bb0a7d4f647" + "3dc07bb0a7d4f647", + "c58cfa3fc57972d1" ], "x": 174, "y": 339, - "w": 552, + "w": 572, "h": 202, "info": "# Methods\n\nThis sub-group is provides the http endpoints for the supported methods." }, @@ -3481,8 +3482,8 @@ "links": [ "2f1060b185e19215" ], - "x": 630, - "y": 400, + "x": 650, + "y": 380, "wires": [], "icon": "font-awesome/fa-lock", "l": true @@ -3527,8 +3528,8 @@ "z": "379c65a27117b46c", "g": "cf2a3f84cb26a12c", "name": "Details", - "func": "var cont = null;\nvar callback = null;\nvar not_configured = null;\n\nvar status = {fill:\"red\",shape:\"ring\",text:\"Err: Incomplete\"};\n\nif (\n global.get(\"config\") == undefined ||\n (\n global.get(\"config\") != undefined &&\n global.get(\"config.auth_method\") == undefined\n )\n) {\n\n status.text = 'No Config';\n\n msg.statusCode = 400;\n\n not_configured = msg;\n\n} else {\n\n if ( \n Array(global.get(\"config.auth_method\")).includes('oauth2') &&\n global.get(\"config.oauth2\") == undefined\n ) {\n\n status.text = 'No OAuth2 Config';\n\n msg.statusCode = 400;\n\n not_configured = msg;\n\n }else{\n\n msg.http = {\n \"client\": msg.req.connection.remoteAddress,\n \"headers\": msg.req.headers,\n \"timestamp\": Date.now()\n }\n\n if (msg.req.params[\"0\"] == 'callback' ){\n\n status.fill = 'blue';\n status.text = 'Oauth2 Callback';\n\n callback = msg;\n\n }else{\n\n status.fill = 'green';\n status.text = 'Continue';\n\n cont = msg;\n\n }\n }\n}\nnode.status( status );\n\nnode.send([\n cont,\n callback,\n not_configured\n]);\n", - "outputs": 3, + "func": "var cont = null;\nvar callback = null;\nvar not_configured = null;\nvar http_404 = null\nvar status = {fill:\"red\",shape:\"ring\",text:\"Err: Incomplete\"};\n\nif( msg.req._parsedUrl.path == '/favicon.ico' ) {\n \n status.text = 'HTTP/404';\n status.fill = 'grey';\n\n msg.statusCode = 404;\n msg.payload = {};\n\n http_404 = msg;\n\n} else if (\n global.get(\"config\") == undefined ||\n (\n global.get(\"config\") != undefined &&\n global.get(\"config.auth_method\") == undefined\n )\n) {\n\n status.text = 'No Config';\n\n msg.statusCode = 400;\n\n not_configured = msg;\n\n} else {\n\n if ( \n Array(global.get(\"config.auth_method\")).includes('oauth2') &&\n global.get(\"config.oauth2\") == undefined\n ) {\n\n status.text = 'No OAuth2 Config';\n\n msg.statusCode = 400;\n\n not_configured = msg;\n\n }else{\n\n msg.http = {\n \"client\": msg.req.connection.remoteAddress,\n \"headers\": msg.req.headers,\n \"timestamp\": Date.now()\n }\n\n if (msg.req.params[\"0\"] == 'callback' ){\n\n status.fill = 'blue';\n status.text = 'Oauth2 Callback';\n\n callback = msg;\n\n }else{\n\n status.fill = 'green';\n status.text = 'Continue';\n\n cont = msg;\n\n }\n }\n}\nnode.status( status );\n\nnode.send([\n cont,\n callback,\n not_configured,\n http_404\n]);\n", + "outputs": 4, "noerr": 0, "initialize": "", "finalize": "", @@ -3544,15 +3545,19 @@ ], [ "3dc07bb0a7d4f647" + ], + [ + "c58cfa3fc57972d1" ] ], "outputLabels": [ "Continue", "Oauth2 Callback", - "Server Not Configured" + "Server Not Configured", + "HTTP/404" ], "icon": "font-awesome/fa-info-circle", - "info": "# Details\n\nAdds the HTTP request details to object `msg.http`." + "info": "# Details\n\nAdds the HTTP request details to object `msg.http`. Also checks for favicon.ico and returns HTTP/404." }, { "id": "c43678f82d52004f", @@ -3595,7 +3600,8 @@ "links": [ "5f2f87eeebd5bf6e", "5b97592fe62125c7", - "3dc07bb0a7d4f647" + "3dc07bb0a7d4f647", + "c58cfa3fc57972d1" ], "x": 290, "y": 640, @@ -3675,8 +3681,8 @@ "links": [ "9f416bc258c1a60c" ], - "x": 630, - "y": 440, + "x": 650, + "y": 420, "wires": [], "icon": "font-awesome/fa-lock", "l": true @@ -3779,8 +3785,8 @@ "links": [ "5ad10ea406e2d3a7" ], - "x": 620, - "y": 480, + "x": 640, + "y": 460, "wires": [], "icon": "font-awesome/fa-hand-stop-o", "l": true @@ -3822,6 +3828,22 @@ ], "info": "# GLPI Configuration\n\nThis node stores it's values within `flows_cred.json` and therefor takes advantage of encrypting the values.\n\n## Structure\n\n``` json\n\n{\n \"api_url\": \"http://glpi/apirest.php/\",\n \"authorization\": \"user_token ***\",\n \"app_token\": \"\",\n \"category_id_automation_task\": 0,\n \"debug_on\": false\n}\n\n```\n\n| item | type | description |\n|:---:|:---:|:---|\n| api_url | `string` | URL for the API `{protocol}://{domain}/apirest.php/` |\n| authorization | `string` | Auth token suffixed with `user_token` |\n| app_token | `string` | Application token |\n| category_id_automation_task | `int` | the category for this automation task to be applied to the ticket task |\n| debug_on | `bool` | Authentication Callback URL, this value must always be `{protocol}://{domain}/callback`. i.e. `http://127.0.0.1:1881/callback` |\n " }, + { + "id": "c58cfa3fc57972d1", + "type": "link out", + "z": "379c65a27117b46c", + "g": "cf2a3f84cb26a12c", + "name": "HTTP/404", + "mode": "link", + "links": [ + "5ad10ea406e2d3a7" + ], + "x": 650, + "y": 500, + "wires": [], + "icon": "font-awesome/fa-hand-stop-o", + "l": true + }, { "id": "02c4b9524d361ade", "type": "link in", -- 2.49.0