Authentication vs Authorization
Verifying who you are (AuthN) vs determining what you are permitted to do (AuthZ) — Deep technical analysis of trade-offs, architecture, performance, security postures, and engineering decision frameworks.
Web Protocols & Security Architecture Research
What is the difference between AuthN and AuthZ?
Authentication always precedes Authorization: a system must establish who an identity is before it can determine what permissions that identity possesses.
What are AuthN and AuthZ?
Authentication (AuthN)
The verification mechanism that proves the identity of an agent (user, service, device) using credentials such as knowledge factors (passwords), possession factors (hardware keys), or inherence factors (biometrics).
Authorization (AuthZ)
The policy decision and enforcement mechanism that determines whether an authenticated principal is allowed to perform a given operation on a given target resource.
3. Side-by-Side Comparison Matrix
| Feature / Dimension | AuthN | AuthZ | Advantage |
|---|---|---|---|
Core Question Sequential, dependent processes | Who are you? | What are you allowed to do? | Tie / Context |
Sequence Order You cannot authorize an unknown entity | First (Step 1) | Second (Step 2) | Tie / Context |
Common Protocols Distinct standards govern each domain | OpenID Connect, SAML, WebAuthn, FIDO2 | OAuth 2.0, XACML, Zanzibar, OPA | Tie / Context |
Data Transmitted Identity attributes vs permission sets | User identity, email, sub ID, MFA status | Roles, permissions, scopes, access levels | Tie / Context |
Visibility to User AuthN is user-interactive; AuthZ is systemic | Visible (login screens, biometric prompts) | Invisible (background policy checks) | Tie / Context |
HTTP Status Code on Failure HTTP specification confusingly uses 401 for AuthN failure | 401 Unauthorized (actually Unauthenticated) | 403 Forbidden | Tie / Context |
How do AuthN and AuthZ differ technically?
Identity Verification vs Privilege Enforcement
Authentication confirms a person is Alice. Authorization determines that Alice can read document #42, but cannot edit document #42 or view document #43.
HTTP Status Code Confusion (401 vs 403)
The HTTP specification has a notorious naming defect: status 401 is named "Unauthorized", but RFC 9110 clarifies it means unauthenticated (missing or invalid credentials). Status 403 "Forbidden" means the identity is authenticated, but lacks permissions.
Static vs Dynamic Evaluation
Authentication typically occurs once per session (e.g. at login). Authorization is evaluated continuously on every HTTP request and button click based on context (time of day, resource ownership, project tenancy).
When should you use AuthN vs AuthZ?
When to Use AuthN
User Onboarding & Login Portals
Verifying user credentials when initiating an active session.
Step-Up Security for Sensitive Actions
Re-prompting for biometrics or MFA before wire transfers or password changes.
Machine Identity Handshakes
Mutual TLS (mTLS) certificate verification between microservices.
When to Use AuthZ
Role-Based Endpoint Protection
Ensuring only users with the "admin" role can access /api/v1/users/delete.
Multi-Tenant Resource Scoping
Enforcing that users in Tenant A can never query or modify records belonging to Tenant B.
Third-Party API Scope Checking
Verifying an OAuth token contains "scope: write:repo" before executing a git push.
What are the security differences between AuthN and AuthZ?
AuthN vulnerabilities involve credential stuffing, phishing, brute force, and MFA bypass. AuthZ vulnerabilities include Broken Object Level Authorization (BOLA/IDOR), Privilege Escalation, and missing functional access controls.
- ×Credential stuffing and brute-force password spraying
- ×Adversary-in-the-Middle (AiTM) phishing intercepting session tokens
- ×Session hijacking and token fixation
- ×Broken Object Level Authorization (BOLA / IDOR - OWASP API #1)
- ×Broken Function Level Authorization (privilege escalation to admin)
- ×Insecure Direct Object References in SQL or REST endpoints
- For AuthN: enforce phishing-resistant WebAuthn passkeys or FIDO2 hardware keys with TOTP fallbacks.
- For AuthZ: enforce authorization checks on EVERY database query by filtering by tenant_id and user_id.
- Never rely on client-side UI hiding for security; every API route must independently enforce authorization.
Which performs better: AuthN or AuthZ?
AuthN has high one-time latency at login (password hashing algorithms like Argon2id intentionally consume 50–100ms of CPU). AuthZ must execute in sub-millisecond time on every request.
| Benchmark Metric | AuthN | AuthZ |
|---|---|---|
| Computation Cost | Heavy CPU on login (Argon2 / bcrypt / WebAuthn) | Ultra-light in-memory policy lookup (<1ms) |
| Frequency | Once per session or token refresh | Every single API request and database query |
| Caching Potential | Cached in active session/token | Policy cached; resource ownership dynamically checked |
9. Side-by-Side Concrete Technical Examples
import * as argon2 from 'argon2';
export async function authenticateUser(passwordInput: string, storedHash: string): Promise<boolean> {
// Proves WHO the user is by verifying knowledge of secret
const isValid = await argon2.verify(storedHash, passwordInput);
if (!isValid) {
throw new Error('Authentication failed: Invalid credentials'); // 401
}
return true;
}interface RequestUser { id: string; role: 'admin' | 'member'; tenantId: string; }
interface Document { id: string; ownerId: string; tenantId: string; }
export function authorizeDocumentEdit(user: RequestUser, doc: Document): boolean {
// Enforces WHAT the authenticated user is allowed to do
if (user.tenantId !== doc.tenantId) {
throw new Error('Forbidden: Cross-tenant access denied'); // 403
}
const isOwner = user.id === doc.ownerId;
const isAdmin = user.role === 'admin';
if (!isOwner && !isAdmin) {
throw new Error('Forbidden: Insufficient privileges'); // 403
}
return true;
}What are common misconceptions about AuthN vs AuthZ?
Despite its name, HTTP 401 means UNAUTHENTICATED. HTTP 403 Forbidden is the true UNAUTHORIZED status code.
Authentication only proves identity. A user may successfully authenticate with a valid Google login, but be rejected by authorization because they lack an active enterprise license or team membership.
Which should you choose: AuthN or AuthZ?
Architect authentication and authorization as separate concerns. Delegate authentication to modern identity providers using OIDC and WebAuthn. Build authorization as a dedicated layer enforcing tenant isolation and object ownership on every database query.
Frequently Asked Questions About AuthN vs AuthZ
Q:Can you have authorization without authentication?
A system might authorize anonymous visitors to read content while requiring authentication before authorizing comment submissions.
Q:What is BOLA / IDOR in authorization?
BOLA consistently ranks as the #1 vulnerability on the OWASP API Security Top 10 because developers frequently authenticate the user, but forget to verify object authorization.
13. Related Client-Side Verification Tools
Inspect, test, and benchmark these technologies directly in your browser with 100% private client-side execution: