Hello, I have created a common Authentication Flow, where all the endpoints before proceeding with its actual task, needs to go through this authentication process and continue if the status of the Authentication Flow is success else return failure response. For this I am using the link in and link out nodes. I need to know how to use them in my flow.
The following is my authentication flow :
[{"id":"3a61fed1.4aa072","type":"tab","label":"Authentication Flow","disabled":false,"info":""},{"id":"4b32e7a4.bdf37","type":"http in","z":"3a61fed1.4aa072","name":"","url":"/secure","method":"post","upload":false,"swaggerDoc":"","x":170,"y":400,"wires":[["a147469f.d5cb5","eac4412f.6ddd1"]]},{"id":"4eeb8722.ec4b4","type":"http response","z":"3a61fed1.4aa072","name":"Failure response","statusCode":"400","headers":{},"x":910,"y":660,"wires":[]},{"id":"1ab8b951.bac427","type":"http response","z":"3a61fed1.4aa072","name":"Match Success Response","statusCode":"200","headers":{},"x":1300,"y":460,"wires":[]},{"id":"5b08a105.205fe8","type":"change","z":"3a61fed1.4aa072","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"token","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":340,"wires":[["1ab8b951.bac427"]]},{"id":"eac4412f.6ddd1","type":"function","z":"3a61fed1.4aa072","name":"query","func":"var DBTOKEN = global.get('spoorsdevconfig').oracledbschema + `.` + global.get('spoorsdevconfig').tableAUTH;\nnode.log(\"DBTOKEN==>\" + DBTOKEN)\nmsg.payload={};\nmsg.payload = { \n \"queryName\": \"\",\n \"msgArray\": [],\n \"query\": `select * from ` + DBTOKEN + ``\n}\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":400,"wires":[["67d578c6.5c6ac8","136ee21e.f7d966"]]},{"id":"8f994dee.35e378","type":"function","z":"3a61fed1.4aa072","name":"Verifying Token","func":"if (msg.req.headers.clientid && msg.req.headers.authorization) { \n var dbToken = msg.responsedata[0][2];\n var dbCId = msg.responsedata[0][0];\n\n if((msg.req.headers.clientid == dbCId) && \n (msg.req.headers.authorization === msg.responsedata[0][2]))\n {\n msg.statusCode = 200;\n msg.token = msg.req.headers.authorization;\n node.log(\"Successfully logged in\")\n node.send(msg);\n }\n else \n {\n msg.statusCode = 401;\n node.log(\"Unauthorized access\")\n node.send([null, msg]); \n }\n }\n else {\n msg.statusCode = 400;\n node.log(\"Token Missing\")\n node.send([null, msg]);\n}","outputs":3,"noerr":0,"x":660,"y":440,"wires":[["4a5771ce.87449"],["74385fba.4bfc1"],["b85b6135.57ba48"]]},{"id":"8c4e53f3.1b051","type":"http response","z":"3a61fed1.4aa072","name":"Match Failure Response","statusCode":"401","headers":{},"x":1050,"y":520,"wires":[]},{"id":"74385fba.4bfc1","type":"function","z":"3a61fed1.4aa072","name":"","func":"var res = {};\n\nres.status = 'Unauthorized access';\n\nres.message = 'Invalid Credentials';\n\nmsg.payload = res;\n\nreturn msg;","outputs":1,"noerr":0,"x":930,"y":440,"wires":[["8c4e53f3.1b051"]]},{"id":"b85b6135.57ba48","type":"function","z":"3a61fed1.4aa072","name":"","func":"var res = {};\n\nres.status = 'Unauthorized access';\n\nres.message = 'Invalid Credentials';\n\nmsg.payload = res;\n\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":560,"wires":[["4eeb8722.ec4b4"]]},{"id":"67d578c6.5c6ac8","type":"debug","z":"3a61fed1.4aa072","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":300,"wires":[]},{"id":"2750bf59.4f825","type":"debug","z":"3a61fed1.4aa072","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":555.8333740234375,"y":590.1190795898438,"wires":[]},{"id":"a147469f.d5cb5","type":"debug","z":"3a61fed1.4aa072","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":140,"y":600,"wires":[]},{"id":"cd96fcb9.2b0a6","type":"inject","z":"3a61fed1.4aa072","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":240,"wires":[["eac4412f.6ddd1"]]},{"id":"136ee21e.f7d966","type":"oracle-db","z":"3a61fed1.4aa072","name":"","x":520,"y":500,"wires":[["8f994dee.35e378","2750bf59.4f825"]]},{"id":"4a5771ce.87449","type":"JsonWebToken","z":"3a61fed1.4aa072","name":"Decrypt","tokenconfig":"776a7e3c.62f7c8","x":805.2083129882812,"y":322.7083435058594,"wires":[["5b08a105.205fe8"]]},{"id":"1f8dcdec.ef2dc2","type":"link in","z":"3a61fed1.4aa072","name":"","links":["1fdec263.874fd6","60a2cc0a.8b5cbc","696d140.b51dfec","7b7759f1.bae578","8fcb76ed.4c111","95a7a2d6.31c23","97c14d32.aba32","bfde62d4.f388a8","e27f2bfd.b20ad","ee7e67e9.8cdee"],"x":375,"y":160,"wires":[["eac4412f.6ddd1","7400bd3b.dfcf1c"]]},{"id":"7400bd3b.dfcf1c","type":"link out","z":"3a61fed1.4aa072","name":"","links":["7bd15570.9161ec","81e3321a.fd8228","677b3081.c35"],"x":555,"y":100,"wires":[]},{"id":"776a7e3c.62f7c8","type":"JsonWebToken_config","z":"","name":"My Secret Key","secret":"dshjfjkfgi2345ggyhujkdghy58uirjefut7685irofkf/riuhggkoHJKyujk"}]
I am trying to link it to my other endpoints in the following way
[{"id":"659d8993.948e3","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4b9d564c.8a873","type":"debug","z":"659d8993.948e3","name":"","active":true,"console":"false","complete":"false","x":1130,"y":380,"wires":[]},{"id":"88e3619e.8e1ed8","type":"html","z":"659d8993.948e3","name":"","property":"","tag":".node-red-latest-version","ret":"text","as":"single","x":820,"y":400,"wires":[["4b9d564c.8a873"]]},{"id":"163f2a04.c0dcbe","type":"http in","z":"659d8993.948e3","name":"","url":"https://nodered.org","method":"get","upload":false,"swaggerDoc":"","x":320,"y":400,"wires":[["10b0675b.6d4c81","bfde62d4.f388a8"]]},{"id":"10b0675b.6d4c81","type":"function","z":"659d8993.948e3","name":"Verify Auth","func":"\nif(msg.statusCode == '200'){\n\n node.send([msg,null]); \n \n}else{\n \n node.send([null,msg]); \n \n}","outputs":2,"noerr":0,"x":550,"y":400,"wires":[["88e3619e.8e1ed8"],["4d01e080.4e68f","8fcb76ed.4c111"]]},{"id":"bfde62d4.f388a8","type":"link out","z":"659d8993.948e3","name":"","links":["1f8dcdec.ef2dc2"],"x":495,"y":280,"wires":[]},{"id":"4d01e080.4e68f","type":"http response","z":"659d8993.948e3","name":"Failure Response","statusCode":"401","headers":{},"x":650,"y":560,"wires":[]},{"id":"8fcb76ed.4c111","type":"link out","z":"659d8993.948e3","name":"","links":["1f8dcdec.ef2dc2"],"x":716.1666259765625,"y":466.16668701171875,"wires":[]}]
Maybe, I am not using the link node properly.
Thanks in Advance.