This repository is made to provide code samples used in the post I created for wannabedev.io titled "Everything you need to know about JSON Web Token". You can find the whole blog post here.
I recommend reading the article first and then coming back to experiment with the code. This example uses the jose npm module. Make sure to install the required dependencies by running:
npm installRSA keys are already created and stored in the keys directory. There, you can find public and private keys.
keys
├── private.pem
└── public.pemIn case you want to create new RSA keys, you can use generate-rsa-key-pair.js and generate a new pair by running:
node generate-rsa-key-pair.jsTo get the fresh JWT, run the following command:
node authentication-server.jsCopy the token and modify userToken by providing the newly generated token. After that, run the following command to verify the token:
node application-server.jsFeel free to experiment with token configurations in authentication-server.js and see how they affect token verification in application-server.js.
This repository is only made for learning purposes; do not use it in production or commercial projects.
Follow WANNABEDEV: GitHub, Twitter (X), Instagram, TikTok
