ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)
How does JWT Authentication and Refresh Token Rotation work in ASP.NET Core?
senior LevelMost AskedSecurity & AuthSystem Design
In Simple Words:
- Configure
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(...). - Validate
Issuer,Audience,IssuerSigningKey, and clock skew. - Access tokens expire quickly (15 mins).
- Refresh tokens are stored in the database with a family ID. On refresh, the old token is invalidated and a new pair is issued (Refresh Token Rotation). If an already-used refresh token is presented, the whole family is revoked (detecting token theft).