1️⃣ What is the difference between Authentication and Authorization?
Answer:
- Authentication verifies who the user is (e.g., login).
- Authorization controls what the user can access (e.g., admin vs user access).
2️⃣ What is JWT (JSON Web Token)?
Answer:
A compact token used for stateless authentication. It contains a header, payload (user info), and signature to verify data integrity.
3️⃣ How is JWT more secure than traditional sessions?
Answer:
JWTs are stored on the client-side and signed with a secret. Unlike sessions, they don’t require server-side storage, making them scalable and tamper-evident.
4️⃣ What's the difference between Cookies and LocalStorage?
Answer:
- Cookies: Automatically sent with each HTTP request, smaller in size, can be
HttpOnly. - LocalStorage: Larger, persists longer, not sent with requests (manual access only).
5️⃣ What is CORS? Why is it important?
Answer:
CORS (Cross-Origin Resource Sharing) is a browser mechanism that restricts requests from different origins. It protects against unwanted cross-site access.
6️⃣ What is CSRF and how do you prevent it?
Answer:
CSRF (Cross-Site Request Forgery) tricks a logged-in user into submitting unwanted actions.
Prevention: Use CSRF tokens,
SameSite cookies, and avoid storing sensitive data in localStorage.7️⃣ What is XSS and how do you prevent it?
Answer:
XSS (Cross-Site Scripting) injects malicious scripts into web pages.
Prevention: Escape user input, use Content Security Policy (CSP), and sanitize HTML.
8️⃣ What is HTTPS and why is it critical?
Answer:
HTTPS encrypts data using SSL/TLS. It ensures data privacy, integrity, and trust between client and server.
9️⃣ How do you implement password security in web apps?
Answer:
- Store hashed passwords using bcrypt or Argon2
- Use salting
- Enforce strong password rules
- Implement rate-limiting on login attempts
🔟 What is OAuth?
Answer:
OAuth is an authorization protocol that allows users to grant access to third-party apps without sharing credentials (e.g., login with Google/Facebook).
💬 Tap ❤️ if you found this useful!