Server-Side Authorization Enforcement
What you'll learn: You'll understand why all authorization decisions must happen on the server, not in the browser or client application.
The Core Problem
When building web applications, it's tempting to hide buttons, disable features, or check permissions using JavaScript in the browser. While this creates a smooth user experience, it provides zero security.
Think of it like a bank vault: putting up a "Staff Only" sign doesn't stop anyone from walking in if the door is unlocked. The real lock must be on the vault itself, not just the sign.
Why Client-Side Checks Are Dangerous
Any code running in a browser or mobile app can be:
- Modified using browser dev tools
- Bypassed by crafting direct HTTP requests
- Manipulated by altering API calls or parameters
- Replayed with different user contexts
An attacker doesn't need to see your "Admin Panel" button to call /api/deleteUser directly. They can use tools like curl, Postman, or Burp Suite to send requests completely outside your UI.
The Server-Side Solution
Every single authorization decision must be made on the server, typically:
- Before processing any request - Check if the authenticated user has permission
- On every endpoint - Even internal APIs or "hidden" routes
- Independent of the client - Never trust what the client says about permissions
The server should ask: "Does this specific user have permission to perform this specific action on this specific resource?" before executing any sensitive operation.
Client-side checks are fine for UX (hiding irrelevant buttons), but they're window dressing—the real enforcement happens server-side.
Key Takeaway: Authorization is a server-side responsibility; client-side checks are purely cosmetic and must never be relied upon for security. Always validate permissions on the server before processing any request.