Recall & Review
beginner
What is the main purpose of JWT token verification middleware in an Express app?
It checks if the incoming request has a valid JWT token to allow access to protected routes.
Click to reveal answer
beginner
Which HTTP header usually carries the JWT token in requests?
The 'Authorization' header, often with the format 'Bearer <token>'.
Click to reveal answer
beginner
What happens if the JWT token is missing or invalid in the verification middleware?
The middleware sends a 401 Unauthorized response and stops the request from reaching protected routes.
Click to reveal answer
intermediate
How does the middleware verify the JWT token?
It uses a secret key or public key to decode and check the token's signature and expiration.
Click to reveal answer
intermediate
Why is it important to place JWT verification middleware before protected route handlers?
So that only requests with valid tokens can access those routes, protecting sensitive data or actions.
Click to reveal answer
Which Express middleware function is best for verifying JWT tokens?
✗ Incorrect
JWT verification middleware reads the Authorization header to check the token's validity.
What status code should the middleware return if the JWT token is invalid?
✗ Incorrect
401 Unauthorized indicates the client is not authorized due to invalid or missing credentials.
Where is the JWT token usually stored on the client side for sending with requests?
✗ Incorrect
Clients often store JWT tokens in cookies or local storage to send them in Authorization headers.
Which library is commonly used in Express apps to verify JWT tokens?
✗ Incorrect
The 'jsonwebtoken' library provides functions to sign and verify JWT tokens.
What does the 'Bearer' keyword in the Authorization header mean?
✗ Incorrect
'Bearer' means the token is a bearer token, which grants access to the bearer.
Explain how JWT token verification middleware works in an Express app.
Think about the steps from receiving a request to deciding if it can access protected routes.
You got /5 concepts.
Describe why JWT token verification middleware is important for securing Express routes.
Consider what could happen if you skip token checks on protected routes.
You got /4 concepts.