Spring Boot

JWT & Stateless Security

Stateless security with JWT, token generation and validation, security filters, refresh tokens

20 câu hỏi phỏng vấn·
Senior
1

What is the structure of a JWT (JSON Web Token)?

Câu trả lời

A JWT consists of three parts separated by dots: Header (algorithm and type), Payload (claims/data), and Signature (integrity verification). Each part is Base64URL encoded. This structure allows secure and verifiable information transmission between two parties.

2

Which JWT claim represents the subject (user) of the token?

Câu trả lời

The 'sub' (subject) claim identifies the JWT's subject, typically the authenticated user (e.g., user ID or username). It's a standard claim defined in RFC 7519. Other standard claims include 'iss' (issuer), 'exp' (expiration), 'iat' (issued at), 'aud' (audience), and 'jti' (JWT ID).

3

What is the main difference between HMAC and RSA signing algorithms for JWT?

Câu trả lời

HMAC (e.g., HS256) uses a shared symmetric secret key to sign and verify, while RSA (e.g., RS256) uses an asymmetric key pair (private to sign, public to verify). RSA is preferable when multiple services need to verify tokens without accessing the signing key, as in microservices architectures.

4

Which JWT claim defines the token expiration date?

5

How should a client send a JWT in an HTTP REST request?

+17 câu hỏi phỏng vấn

Nắm vững Spring Boot cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí