You Can't Understand Authentication Without this
AUTHENTICATION
(Conceptual + Developer Point of View)
1. What is Authentication?
Authentication is the process of verifying the identity of a user, device, or system before allowing access to resources.
👉 It answers the question:
“Who are you?”
Simple Definition
Authentication ensures that an entity is genuinely who or what it claims to be.
Examples
Logging into email using username and password
Unlocking a phone using fingerprint
API verifying a JWT token
2. Authentication vs Authorization
| Aspect | Authentication | Authorization |
|---|---|---|
| Meaning | Identity verification | Permission checking |
| Question | Who are you? | What can you do? |
| Order | First | After authentication |
| Example | Login | Access admin page |
3. Authentication Factors (Foundation)
Authentication methods are based on factors:
Something you know
(Password, PIN)Something you have
(OTP, smart card, phone)Something you are
(Biometrics)
4. User-Level Types of Authentication
4.1 Single-Factor Authentication (SFA)
Definition:
Uses only one factor, usually a password.
Working
User enters username
User enters password
System verifies credentials
Access granted or denied
Where to Use
Low-security systems
Personal devices
Characteristics
✔ Simple
✔ Fast
✖ Weak security
✖ Vulnerable to attacks
Diagram
4.2 Two-Factor Authentication (2FA)
Definition:
Uses two different authentication factors.
Working
Password verification
OTP sent to device
OTP verified
Access granted
Examples
ATM card + PIN
Email + OTP
Where to Use
Banking
Email
Social media
Characteristics
✔ Better security
✔ Protects against stolen passwords
✖ Slightly slower
Diagram
4.3 Multi-Factor Authentication (MFA)
Definition:
Uses two or more independent factors.
Factors Used
Password
OTP / hardware token
Biometric
Where to Use
Enterprises
Cloud platforms
Military systems
Characteristics
✔ Very high security
✔ Strong attack resistance
✖ Complex setup
✖ Costly
Diagram
5. Biometric Authentication
Definition:
Authentication using biological characteristics.
Types
Fingerprint
Face recognition
Iris scan
Voice recognition
Working
Biometric captured
Compared with stored template
Match → Access
Characteristics
✔ Very secure
✔ Convenient
✖ Privacy risks
✖ Cannot be changed if leaked
Diagram
6. Certificate-Based Authentication
Definition:
Authentication using digital certificates issued by a trusted authority (CA).
Working
Client sends certificate
Server verifies with CA
Secure connection established
Use Cases
HTTPS
Enterprise networks
Secure APIs
Characteristics
✔ Very secure
✔ No passwords
✖ Certificate management overhead
Diagram
AUTHENTICATION (Developer Point of View)
7. Why Developers Need Special Authentication Mechanisms
HTTP is stateless
Servers must remember authenticated users
Requires sessions, tokens, or identity providers
8. Common Developer Authentication Approaches
Session-Based Authentication
Token-Based Authentication (JWT)
OAuth 2.0
OpenID Connect (OIDC)
API Key Authentication
9. Session-Based Authentication
What is it?
Server stores authentication state using sessions.
Working
User logs in
Server creates session ID
Session stored server-side
Session ID sent in cookie
Cookie sent with each request
Where to Use
Traditional web apps
Server-rendered applications
Characteristics
✔ Easy logout
✔ Simple
✖ Not scalable
✖ Hard for microservices
Diagram
10. Token-Based Authentication
What is it?
Authentication using self-contained tokens, not server sessions.
Working
User logs in
Token generated
Client stores token
Token sent in headers
Server validates token
Use Cases
REST APIs
Microservices
Mobile apps
Characteristics
✔ Stateless
✔ Scalable
✖ Token revocation difficult
Diagram
11. JWT (JSON Web Token)
What is JWT?
A stateless, compact, signed token used for authentication.
JWT Structure
HEADER.PAYLOAD.SIGNATURE
| Part | Purpose |
|---|---|
| Header | Algorithm info |
| Payload | Claims (user data) |
| Signature | Prevents tampering |
Working
Login success
JWT created and signed
Client stores JWT
JWT sent in Authorization header
Server verifies signature
Where to Use
SPAs
REST APIs
Mobile apps
Characteristics
✔ No server storage
✔ Fast
✖ Cannot easily revoke
✖ Data is readable
Diagram
12. OAuth 2.0
What is OAuth?
An authorization framework (not authentication).
OAuth answers: “Can this app access user data?”
Real Examples
Login with Google
Login with GitHub
OAuth Roles
| Role | Description |
|---|---|
| Resource Owner | User |
| Client | App |
| Authorization Server | |
| Resource Server | API |
Authorization Code Flow
User redirected to provider
User gives consent
Authorization code returned
Code exchanged for token
Token accesses API
Characteristics
✔ No password sharing
✔ Secure delegation
✖ Complex
Diagram
13. OpenID Connect (OIDC)
What is OIDC?
Authentication layer on top of OAuth 2.0
OAuth + Identity = OIDC
Key Concept
ID Token (JWT) confirms user identity
Working
OAuth login
Access token + ID token issued
ID token verified
User authenticated
Use Cases
SSO
Enterprise login
Cloud services
Diagram
14. API Key Authentication
What is it?
Authentication using a static API key.
Working
Client sends API key
Server validates key
Access granted
Use Cases
Internal APIs
Server-to-server calls
Characteristics
✔ Simple
✔ Fast
✖ Weak security
✖ Not user-based
Diagram
15. Comparison Table (Complete View)
| Method | Stateful | Security | Scalability | Use Case |
|---|---|---|---|---|
| SFA | Yes | Low | Low | Basic systems |
| 2FA | Yes | Medium | Medium | Banking |
| MFA | Yes | Very High | Medium | Enterprises |
| Session | Yes | Medium | Low | Web apps |
| JWT | No | High | High | APIs |
| OAuth | No | Very High | High | Social login |
| OIDC | No | Very High | High | SSO |
| API Key | No | Low | Medium | Internal APIs |
16. Key Exam & Interview Takeaways
Authentication verifies identity
Authorization controls permissions
JWT is stateless
OAuth ≠ Authentication
OIDC = OAuth + Identity
MFA is strongest user-level security
17. One-Line Memory Hooks
Password → Knowledge
OTP → Possession
Biometric → Identity
Session → Server remembers
JWT → Token remembers
OAuth → Delegate access
OIDC → Verify identity
If you want next, I can give you:
Exam-ready short answers
JWT vs Session (deep)
OAuth flows with diagrams
Spring Boot / Node.js auth code
Security pitfalls & best practices
Just tell me 👍
Comments