Virtusa Interview Question

How does JWT authentication work, and how would you make it more secure in a production environment?

Interview Answer

Anonymous

Aug 29, 2025

I explained that JWT (JSON Web Token) is a compact way of securely transmitting information between parties as a JSON object. The server signs the token using a secret key (or private key in case of RSA), and the client includes this token in the Authorization header for subsequent requests. To make it more secure in production: Always use HTTPS to prevent token interception. Set an expiry time for tokens to limit damage if stolen. Use refresh tokens with short-lived access tokens. Store tokens in HTTP-only cookies instead of localStorage to reduce XSS risk. Implement token blacklisting on logout or password reset.