Skip to Content
Mengty Learns
Security

Authentication vs Authorization (RBAC, ABAC, ReBAC & BOLA)

How authentication and authorization differ, how RBAC, ABAC, and ReBAC model permissions, and how to prevent Broken Object-Level Authorization (BOLA).

explanationbeginnerTested with asvs 5.0.0 (V6, V8), owasp_top_10 2025 (A01)Updated Nov 26, 2026

TL;DR

Authentication (AuthN) proves who you are; Authorization (AuthZ) decides what you can touch. Most real-world breaches in A01:2025 Broken Access Control happen when an API checks AuthN and route-level roles, but forgets object-level ownership (BOLA).

Intent

TL;DR

Separate identity verification from policy enforcement, choose between RBAC, ABAC, and ReBAC for your domain, and enforce deny-by-default object checks on every server handler.

Problem

Teams often treat "logged in" as "allowed", or hide admin buttons in the frontend while leaving /api/invoices/:id open to any authenticated user who guesses another tenant's numeric ID. Without a clear boundary between AuthN and AuthZ, permission checks get scattered across controllers and silently missed on new endpoints.

AuthN establishes identity; AuthZ enforces permission boundaries before any data is read or mutated.

Solution

Enforce deny-by-default authorization in a central policy layer after authentication succeeds:

  1. RBAC (Role-Based Access Control): Assign permissions to roles (viewer, editor, admin). Example: role === 'editor' can publish blog posts.
  2. ABAC (Attribute-Based Access Control): Evaluate attributes of the subject, resource, and environment. Example: user.department === resource.department && request.ip in corpCIDR.
  3. ReBAC (Relationship-Based Access Control): Evaluate graph relationships between users and objects. Example: user is an owner of folder_A, which contains doc_42.
  4. Permission boundaries & BOLA prevention: Always scope database queries by the authenticated principal.id or tenant.id from the server session—never trust userId or role sent in the request body or query string.

Real-world analogy

▶ Flow: watch it work

Request → AuthN → AuthZ Policy Check → Resource (with Deny Path)

Overview of Request → AuthN → AuthZ Policy Check → Resource (with Deny Path). 8 steps.
Overview8 steps in this flow

Press Start or tap any step dot to trace the path.

▸All steps (8)

Code

Always pair authentication with an explicit object-level authorization check on the server:

// UNSAFE: checks AuthN (user is logged in), but trusts :id without ownership check (BOLA)
app.get('/api/orders/:id', requireAuth, async (req, res) => {
  const order = await db.orders.findUnique({ where: { id: req.params.id } });
  return res.json(order);
});

// SAFE: scopes the lookup/policy check to the authenticated principal (ASVS V8)
app.get('/api/orders/:id', requireAuth, async (req, res) => {
  const order = await db.orders.findUnique({ where: { id: req.params.id } });
  if (!order) return res.status(404).json({ error: 'Not found' });

  const isOwner = order.ownerId === req.user.id;
  const isSupportAdmin = req.user.role === 'admin' && req.user.tenantId === order.tenantId;
  if (!isOwner && !isSupportAdmin) {
    return res.status(403).json({ error: 'Forbidden' });
  }

  return res.json(order);
});

When to use / when to avoid

When to use
  • Use RBAC when permissions map cleanly to a small, stable set of job roles (viewer, editor, admin).
  • Use ABAC when access depends on dynamic context (department, tenant plan, IP range, time window).
  • Use ReBAC when sharing and nested ownership graphs drive access (Google Drive-style folders and teams).
When to avoid
  • Never rely on frontend route guards or hidden UI buttons as an authorization boundary.
  • Do not encode mutable permissions into long-lived JWTs if role revocations must take effect immediately.

How to implement

Authenticate once at the boundary

Validate the session or token in middleware and attach an immutable principal object to the request context.

Deny by default

Reject any route that does not declare an explicit authorization policy.

Enforce object- and function-level checks

Check both can this role call this endpoint (no BFLA) and can this user access this specific record (no BOLA).

Test negative paths

Write integration tests where User A requests User B's resource ID and assert 403 (or 404).

Pros / Cons

Pros
  • Centralized policy checks make security audits and unit tests straightforward.
  • Scoping queries by principal/tenant prevents BOLA even when a developer forgets an if-statement.
Cons
  • RBAC alone suffers from role explosion as exceptions accumulate.
  • ReBAC requires maintaining an authorization graph or relationship store alongside application data.

Relations

Check yourself

Check Yourself

1. User A logs in with a valid token and requests GET /api/invoices/500, which belongs to User B, and the server returns it. What vulnerability is this?

2. Which access control model checks whether a user is a member of a parent team that owns a specific document?

Sources