JWT Sign and Verify Example

Flow Example:

Inject -> Set Data -> Sign -> Verify -> Debug

You need set private key and public key files.

[{"id":"a8f33cd2.570cc","type":"inject","z":"daff281e.2500d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":141,"y":73,"wires":[["2fe68ea3.d01972"]]},{"id":"2fe68ea3.d01972","type":"function","z":"daff281e.2500d8","name":"Set Some data","func":"return {payload:{key:\"value\"}};","outputs":1,"noerr":0,"x":163,"y":167,"wires":[["2ac243bb.d53dbc"]]},{"id":"2ac243bb.d53dbc","type":"jwt sign","z":"daff281e.2500d8","name":"","topic":"","alg":"RS256","exp":3600,"secret":"","key":"/root/privkey.pem","signvar":"payload","storetoken":"token","x":454,"y":79,"wires":[["8215562f.7deaa8","151df455.eae20c"]]},{"id":"8215562f.7deaa8","type":"debug","z":"daff281e.2500d8","name":"","active":true,"console":"false","complete":"true","x":750,"y":134,"wires":[]},{"id":"151df455.eae20c","type":"jwt verify","z":"daff281e.2500d8","name":"","topic":"","alg":["RS256","RS384","RS512"],"secret":"","key":"/root/pubkey.pem","signvar":"token","storetoken":"topic","x":456,"y":177,"wires":[["8215562f.7deaa8"],["8215562f.7deaa8"]]}]
chameleonbr

Flow Info

created 1 year, 8 months ago

Node Types

Core
  • debug (x1)
  • function (x1)
  • inject (x1)
Other

Tags

  • jwt
  • sign
  • verify
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option