Skip to content

Code samples used in the post I created for wannabedev.io titled - Everything you need to know about JSON Web Token.

Notifications You must be signed in to change notification settings

rmmgc/everything-you-need-to-know-about-json-web-token

Repository files navigation

About

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.

Everything you need to know about JSON Web Token

How to run

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 install

RSA keys are already created and stored in the keys directory. There, you can find public and private keys.

keys
├── private.pem
└── public.pem

In 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.js

To get the fresh JWT, run the following command:

node authentication-server.js

Copy the token and modify userToken by providing the newly generated token. After that, run the following command to verify the token:

node application-server.js

Feel 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.

Misc

Follow WANNABEDEV: GitHub, Twitter (X), Instagram, TikTok

© WANNABEDEV 2023

About

Code samples used in the post I created for wannabedev.io titled - Everything you need to know about JSON Web Token.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published