Validate HTTP Request APIKey Header
This is an example of how to check incoming HTTP requests for a header called apikey
that should contain a value, in this case 123456
Can be used to secure HTTP Endpoints.
[{"id":"791c52d6ca37529a","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"47273eed8402f2f3","type":"http in","z":"791c52d6ca37529a","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":200,"y":180,"wires":[["6a64b2bed6c9b7b3"]]},{"id":"6a64b2bed6c9b7b3","type":"switch","z":"791c52d6ca37529a","name":"Check API Key","property":"req.headers.apikey","propertyType":"msg","rules":[{"t":"eq","v":"123456","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":440,"y":180,"wires":[["c4f87b095d0b873c"],["31ab0a2086c2245d"]]},{"id":"94f06afe66bd226b","type":"http response","z":"791c52d6ca37529a","name":"","statusCode":"","headers":{},"x":870,"y":200,"wires":[]},{"id":"d9fee09766044d7e","type":"http response","z":"791c52d6ca37529a","name":"","statusCode":"403","headers":{},"x":460,"y":300,"wires":[]},{"id":"31ab0a2086c2245d","type":"template","z":"791c52d6ca37529a","name":"Error Message","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Incorrect or Missing API Key","output":"str","x":440,"y":240,"wires":[["d9fee09766044d7e"]]},{"id":"c4f87b095d0b873c","type":"template","z":"791c52d6ca37529a","name":"Success","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Success!","output":"str","x":700,"y":200,"wires":[["94f06afe66bd226b"]]}]