Go

Security & Authentication

JWT, OAuth2, session management, RBAC, crypto/rand vs math/rand, TLS config, secure coding, security best practices

24 perguntas de entrevistaยท
Senior
1

What is the main difference between JWT tokens and traditional server sessions?

Resposta

JWT tokens are stateless (no server-side state) and contain all necessary information encoded within the token itself. Unlike traditional sessions that store data in memory or database server-side with only a session ID client-side, JWT shifts storage responsibility to the client. This facilitates horizontal scaling as no shared state is required between servers.

2

What are the three parts of a JWT token separated by dots?

Resposta

A JWT consists of three Base64URL-encoded parts separated by dots: Header (algorithm and type), Payload (claims/data), and Signature (integrity verification). The structure is header.payload.signature. The header indicates the signing algorithm (HS256, RS256), the payload contains claims (iss, sub, exp), and the signature ensures the token hasn't been tampered with.

3

Which standard JWT claim defines the token expiration timestamp?

Resposta

The 'exp' (expiration time) claim defines the Unix timestamp after which the token should no longer be accepted. Standard claims also include 'iss' (issuer), 'sub' (subject), 'aud' (audience), 'iat' (issued at), and 'nbf' (not before). Validating the exp claim is crucial to limit token validity duration and reduce the impact of a stolen token.

4

What is the main difference between HS256 and RS256 for signing JWTs?

5

How to revoke a JWT before its natural expiration?

+21 perguntas de entrevista

Domine Go para sua proxima entrevista

Acesse todas as perguntas, flashcards, testes tecnicos, exercicios de code review e simuladores de entrevista.

Comece gratis