ASP.NET Core Interview Question #126
What is authentication in ASP.NET Core?
Authentication, Authorization & Security Mid-Level Intermediate
Quick Interview Answer
Authentication is the process of determining who a user or client is. ASP.NET Core authentication handlers examine credentials such as an authentication cookie, bearer token, certificate, or external-provider response and build a ClaimsPrincipal when authentication succeeds.
Detailed Explanation
Authentication is the process of determining who a user or client is. ASP.NET Core authentication handlers examine credentials such as an authentication cookie, bearer token, certificate, or external-provider response and build a ClaimsPrincipal when authentication succeeds.
Authentication does not decide whether the authenticated identity may access a resource; that is authorization. Applications register one or more authentication schemes and configure defaults when appropriate.
Code Example
builder.Services.AddAuthentication("MyCookie")
.AddCookie("MyCookie");
app.UseAuthentication();
app.UseAuthorization();