
Security & Authentication
JWT, OAuth2, session management, RBAC, crypto/rand vs math/rand, TLS config, secure coding, security best practices
1What is the main difference between JWT tokens and traditional server sessions?
What is the main difference between JWT tokens and traditional server sessions?
Answer
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.
2What are the three parts of a JWT token separated by dots?
What are the three parts of a JWT token separated by dots?
Answer
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.
3Which standard JWT claim defines the token expiration timestamp?
Which standard JWT claim defines the token expiration timestamp?
Answer
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.
What is the main difference between HS256 and RS256 for signing JWTs?
How to revoke a JWT before its natural expiration?
+21 interview questions
Other Go interview topics
Go Basics
Go Data Structures
Go Interfaces
Error Handling
Goroutines Basics
Channels
Go Modules
HTTP Server
HTTP Client
JSON Encoding
database/sql
Context Package
Testing
Concurrency Patterns
Sync Primitives
Go Web Frameworks
REST API Design
gRPC
Reflection
Memory Management
Performance Optimization
Generics
Go Design Patterns
Microservices
Docker & Containerization
Kubernetes Basics
Advanced Go
CLI Development
Master Go for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free