Back
Web Fundamentals

Authorization Best Practices

On this page

easySecurity

Authorization Best Practices

TL;DRAuthenticated ≠ Authorized. Always enforce permissions on the server using RBAC + resource ownership checks.
High Signal
Google
Meta
Netflix
Agoda
30-Second Answerstart every interview with this

Authorization controls what authenticated users are allowed to do. Proper authorization prevents privilege escalation and data leaks. Key principles: least privilege, server-side enforcement, and combining role-based access with resource ownership checks.

Authentication is showing your ID to get in. Authorization is the bouncer checking whether you have a VIP wristband for the VIP area. Even if you're in the club (authenticated), you shouldn't access areas you're not allowed (unauthorized).

User is Authenticated (has valid session)
Request reaches protected endpoint
Server checks permissions (role + ownership)
Allowed → Process | Denied → 403 Forbidden

1Principle of Least Privilege

Users and systems should have the minimum permissions necessary to perform their tasks. This limits damage if credentials are compromised.

2Role-Based Access Control (RBAC)

Map users to roles, and roles to permissions. Simple and effective for most applications.

auth.jsjs
const roles = {
  admin: ['read', 'write', 'delete'],
  editor: ['read', 'write'],
  viewer: ['read']
};

function can(user, action) {
  return roles[user.role]?.includes(action);
}

3Resource Ownership Checks

For user-owned resources (posts, profiles, orders), always verify the requesting user owns the resource in addition to role checks.

PropertyAuthenticationAuthorization
CheckSession / JWT validationRole + ownership verification
ExampleLogin with email/passwordCan this user delete this post?
PurposeWho are you?What are you allowed to do?

Authentication

Check

Session / JWT validation

Example

Login with email/password

Purpose

Who are you?

Authorization

Check

Role + ownership verification

Example

Can this user delete this post?

Purpose

What are you allowed to do?

Common questions

  • ›“What is the difference between authentication and authorization?”
  • ›“How do you implement authorization in a web app?”
  • ›“Explain the principle of least privilege.”
  • ›“How do you protect against unauthorized access to user resources?”

What interviewers look for

  • Clear distinction between authn and authz
  • Server-side enforcement mindset
  • Understanding of RBAC and ownership checks
  • Defense-in-depth thinking (middleware, validation)

Short answer (60 sec)

Authentication verifies identity. Authorization verifies permissions. Always enforce authorization server-side using role checks and resource ownership validation. Follow the principle of least privilege.

Detailed answer (senior level)

Authorization is separate from authentication. Use RBAC for role-based permissions and always check resource ownership for user-specific data. Implement checks in middleware or route handlers. Never trust client-side permission logic. Default to deny (fail securely) and log authorization failures.

  • Assuming authentication is enough (authenticated ≠ authorized)
  • Performing authorization checks only on the client side
  • Missing ownership checks on user resources
  • Using overly broad permissions (admin everywhere)
  • Forgetting to protect all state-changing endpoints
Key Takeaways
  • ✓Authentication = Who are you? Authorization = What can you do?
  • ✓Always enforce authorization on the server
  • ✓Follow principle of least privilege
  • ✓Combine RBAC with resource ownership checks
  • ✓Default to deny access
  • ✓Protect ALL state-changing operations
  • ✓Centralize authorization logic for maintainability

Related web fundamentals topics

Continue with closely related browser and frontend engineering concepts.

Why is HTTPS Secure? Understanding TLS/SSLCookie Security & Session Hardening: SameSite, HttpOnly, SecureContent Security Policy (CSP)CORS Preflight in Practice: Credentials, Simple Requests & MisconfigurationsCORS Explained: Cross-Origin Resource SharingCross-Site Request Forgery (CSRF) Attacks
Previous TopicWhy is HTTPS Secure? Understanding TLS/SSLNext Topic Cookie Security & Session Hardening: SameSite, HttpOnly, Secure