What Is JWT and Why Should You Use JWT

Web Dev Simplified · 1.5M views · 2019 · 14:53

Open on YouTube

Web developmentSecurity & hackingexplainer

Why Stack Overflow recommends it

Stack Overflow users link it when someone is confused about how JWT works, how it differs from sessions, or whether it is safe, as a quick visual primer.

Recommended by 5 people across 5 different months, 2019 to 2022.

What it is

A roughly 15 minute explainer from Web Dev Simplified on what JSON Web Tokens are, how they are built (header, payload, signature), and why the signature makes them tamper-evident. It compares JWT with traditional session-based authentication and ends with when JWT is a good fit.

What people said

Recommends Patrick Lumenus · 2019-11 · Stack Overflow · on “Logout using FeathersJS REST API”

@MartinsUntals Here’s a pretty good video that explains how JWT works, and how it compares to sessions, which is where I think your confusion is coming from. [this video] Hope this helps :)

Recommends Dharmaraj · 2020-11 · Stack Overflow · on “Why need front end stores firebase token?”

Firebase ID Tokens are basically JWT [LINK] , signed by Firebase. Now imagine a scenario where you need to identify the user in your server. You will probably pass the user's UID in the HTTP Request, which is not safe as that can be easily bruteforced unless you have some sort of rate limiting in your server. What I meant by signed? A JWT looks something like: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c The data stored in above JWT is: { "sub": "1234567890", "name": "John Doe", "iat": 1516239022 } You need to verify [LINK] those Firebase IDTokens using Firebase Admin SDK. I don't k

Recommends Mrinal Kamboj · 2021-03 · Stack Overflow · on “How Jwt token issued by IdentiyServer is validate in Web Api Application”

In the question as it seems, that complete OAuth flow using an OAuth or Open Id server is not very clear, let's consider various questions and options. I am using IdentiyServer to issue a JWT Token to a client, token contains role claims and some other claims, this part works fine, I get the the access token with desired claims. Let's segregate the Authentication server from Authorization, generally when we integrate any of the social logins, what they do is provide an access token and we use callback to generate a JWT Authroization token at our server, which we control like Backend server What's the difference between two ? Authentication server generally know very few details about us, mos

Recommends Bravo · 2021-08 · Stack Overflow · on “Is JSON Web Token (JWT) safe?”

I've been of the opinion to use JWT for authorisation, not for authentication- this guy does a decent job of explaining JWT - [this video]

Recommends user16949958 · 2022-06 · Stack Overflow · on “User Roles and rules(permission) access in node.js”

To start out i would recommend you watch dev ed's rest api tutorial followed by understading jwt then jwt authentication tutorial: 1) rest api tutorial: [LINK] 2) jwt authentication understanding: [this video] 3) authentication practical tutorial: [LINK]

Cites Eden Moshe · 2021-01 · Stack Overflow · on “Why JWT Token signing key is required”

You do not need a key to open the encoding, you need a key to verify that nobody changed the contents of the JWT. In fact the string you see is just json's base64 with your information, metadata, and "signature" on all content. The signature is the most important part of a JSON Web Token(JWT). A signature is calculated by encoding the header and payload using Base64url Encoding and concatenating them with a period separator. Which is then given to the cryptographic algorithm. // signature algorithm data = base64urlEncode( header ) + “.” + base64urlEncode( payload ) signature = HMAC-SHA256( data, secret_salt ) So when the header or payload changes, the signature has to calculated again. Only

Cites Schwieriiiiig · 2021-03 · Stack Overflow · on “what is the way to safely exchange data between 2 allowed origins (express, cross origin)”

It looks like you will need more then CORS for your Problem. Try to implement an authentication system with A JSON Web Token ( [LINK] )( [this video] ) or Sessions ( [LINK] ), because Headers can be set manually and can be unreliable. If you have the capabilities, also Try to look into HTTPS, it's more secure, this Thread has more Information on that: Enabling HTTPS on express.js [LINK] And be sure to have a look at the cors module ( [LINK] )! It can be configured for your needs. Just look into the documentation Have a nice day!