wasAsked.

What is Authentication and Authorisation?

Agiliad Technologies Pvt Ltd · Role not specified · technical

Published

Asked in 2026 · Authentication & Security

Community answers

Posted by wasAsked editorial collection

Authentication and authorization are related but answer different questions. Authentication — "Who are you?" - Verifies identity. - Methods: username and password (with hashed passwords), multi-factor authentication (OTP, authenticator apps, passkeys), single sign-on with OpenID Connect or SAML, certificates, API keys for machines. - Result: a trusted identity — for example a session cookie or a token with the user's ID and claims. - Failure response: 401 Unauthorized (the name is historical; it really means "unauthenticated"). Authorization — "What are you allowed to do?" - Decides whether the authenticated identity may access a resource or perform an action. - Models: - Role-based (RBAC): Admin, Manager, User. - Claims or policy-based: rules using attributes such as department or subscription level. - Resource-based: "you can edit only your own orders." - Attribute-based (ABAC): rules combining user, resource and environment attributes. - Failure response: 403 Forbidden (or 404 to avoid revealing that a resource exists). Order: authentication always happens first; you cannot decide permissions without knowing who the user is. Real-life analogy: at an airport, showing your passport is authentication; your boarding pass decides which flight and seat you may access — authorization. In ASP.NET Core: builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(...); builder.Services.AddAuthorization(o => o.AddPolicy("Finance", p => p.RequireRole("Finance"))); app.UseAuthentication(); // establishes HttpContext.User app.UseAuthorization(); // enforces [Authorize] rules [Authorize(Policy = "Finance")] public IActionResult GetPayroll() => ... Best practices: enforce authorization on the server for every request, apply least privilege, check access to specific records (not only roles), and log failures for security monitoring.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics