DEV Community

Discussion on: Understand JWT in 3 minutes

Collapse
 
mjsarfatti profile image
Manuele J Sarfatti

I would like to add that you probably need JWT only in one particular case: when the server or service that authenticates you (i.e. that verifies your identity, where you put your username/password) is DIFFERENT from the server that has to authorize you to take certain actions (e.g. publish a new post).

Typically it's OAuth scenarios, where the user uses the credentials of one system (say an enterprise Active Directory) to perform actions on a second system (a custom app hosted on a different server and domain), where you may want to use JWTs.

In most small/medium apps the server that logs you in is the same that will publish your post (think a standard Laravel app), and in this case the classic ID cookie is the best choice. Simplest and safest.