InterviewBiz LogoInterviewBiz
← Back
What Is Authentication vs Authorization?
software-engineeringmedium

What Is Authentication vs Authorization?

MediumHotMajor: software engineeringokta, google

Concept

Authentication and Authorization are two distinct but complementary concepts in software security.
They determine who can access a system and what actions they can perform.

  • Authentication (AuthN) verifies identity — confirming who the user is.
  • Authorization (AuthZ) defines permissions — determining what the user can do after authentication.

Together, they form the backbone of secure access control in applications, APIs, and systems.


1. Authentication — Verifying Identity

Definition:
Authentication is the process of verifying that a user or system is who they claim to be.
It typically involves credentials like passwords, biometrics, or tokens.

Common Methods:

  • Password-based: Username/password combinations.
  • Token-based: JWT, OAuth 2.0 access tokens.
  • Multi-Factor Authentication (MFA): Combines two or more methods (e.g., password + OTP).
  • Biometric: Fingerprint, face recognition.
  • SSO (Single Sign-On): One login grants access across multiple systems.

Example (safe for MDX):

User: alice@example.com
Password: ********
→ Verified identity = Alice

Outcome: System confirms the identity is valid but does not yet determine what Alice can do.


2. Authorization — Controlling Access

Definition: Authorization determines the resources and actions an authenticated user is permitted to access.

Common Models:

  • RBAC (Role-Based Access Control): Access determined by user roles (e.g., Admin, Editor, Viewer).
  • ABAC (Attribute-Based Access Control): Based on user attributes (e.g., department, location).
  • PBAC (Policy-Based Access Control): Uses policies to define access rules (e.g., XACML).

Example (safe for MDX):

Alice → Authenticated as "user"
System checks role: "admin" required
→ Access Denied (Authorization failed)

Outcome: Even though Alice is authenticated, she’s not authorized for admin-level actions.


3. Comparison Table

AspectAuthenticationAuthorization
DefinitionVerifies user identityGrants or restricts permissions
OrderAlways firstAlways follows authentication
Primary Question“Who are you?”“What are you allowed to do?”
Data SourceCredentials (username, password, token)Role/permission database or policy
OutcomeConfirms identityGrants or denies resource access
ExampleLogging into Google accountAccessing Google Drive admin console
StandardsOAuth 2.0, OpenID Connect, SAML (for AuthN)RBAC, ABAC, ACLs (for AuthZ)

4. Example Flow: Login to a Web App

Scenario:

  1. Authentication: The user logs in using credentials (email + password). The system verifies the identity via an authentication server (e.g., Okta, Auth0, or Firebase Auth).
  2. Authorization: Once authenticated, the system checks if the user’s role or token grants access to requested resources (e.g., admin dashboard).

Flow Diagram (safe for MDX):

[Login Form] → [Auth Server verifies identity] → [JWT issued]
           ↓
[App checks roles/permissions] → [Access Granted or Denied]

5. Real-World Implementations

ExampleAuthenticationAuthorization
Google WorkspaceLogging in with Gmail credentialsAccessing Drive folders based on sharing permissions
AWS ConsoleIAM user login via password/MFAIAM policy grants access to S3 or EC2
GitHubOAuth via GitHub accountRepo access limited to collaborators or teams
Bank AppBiometric login or PINTransaction limits based on user role or account type

6. Common Standards and Protocols

CategoryStandardDescription
AuthenticationOAuth 2.0Delegated access via tokens.
OpenID Connect (OIDC)Identity layer on top of OAuth for user login.
SAML 2.0XML-based authentication standard for enterprise SSO.
AuthorizationRBAC/ABACRole- or attribute-based permissions.
OAuth ScopesDefine permission levels for tokens.
JWT ClaimsEmbed authorization data within tokens.

Example (safe for MDX):

Access Token Scopes:
read:profile
write:email
→ Authorization rules based on token scope

7. Security Best Practices

  • Separate AuthN and AuthZ logic: Use dedicated services (e.g., Okta, Auth0).
  • Use HTTPS: Prevent credential interception.
  • Implement MFA: Protect against stolen credentials.
  • Use short-lived tokens: Reduce risk if compromised.
  • Log access and authorization decisions: Detect anomalies.
  • Principle of Least Privilege (PoLP): Grant only necessary permissions.

8. Common Pitfalls

IssueDescription
Confusing AuthN and AuthZDevelopers often use terms interchangeably, leading to design flaws.
Over-permissive rolesAssigning users broad roles (e.g., “Admin”) instead of granular access.
Token misuseNot validating token scopes or expiration.
Static access listsHardcoded permissions that hinder flexibility and security.

9. Analogy for Understanding

ConceptAnalogy
AuthenticationShowing your ID to a security guard — confirms who you are.
AuthorizationThe guard checking if your ID allows entry into a specific room.

Interview Tip

  • Define both terms clearly and emphasize order (AuthN before AuthZ).
  • Mention real-world protocols (OAuth 2.0, OpenID Connect).
  • Give a practical example (e.g., AWS IAM or web app with roles).
  • Stress principle of least privilege and token-based authorization in modern systems.

Summary Insight

Authentication verifies identity — “Who are you?” > Authorization enforces permissions — “What can you do?” Together, they form the foundation of secure and accountable access control.