Course contentsShow
← Web Development
Lesson 1645 of 2,98230. Web Authorization PatternsFree lesson

Resource-Level Permissions

Checking permissions on specific resources like 'can edit this post' rather than just role-level checks.

Resource-Level Permissions

You'll learn how to check permissions on individual resources, not just user roles.

Beyond Role Checks

Up to now, you've checked if a user has a role like "editor" or "admin" to control what they can do. But what if every editor shouldn't edit every post? Resource-level permissions check if a user has access to a specific resource, like "Can this user edit this particular post?"

This is authorization at the data level, not just the feature level.

The Core Idea

Instead of asking "Is this user an editor?" you ask "Is this user allowed to edit post #42?" This usually involves checking:

  • Ownership: Does this user own the resource?
  • Explicit grants: Was this user given specific permission?
  • Relationship: Does the user's team/organization have access?
  • Status: Is the resource in a state where editing is allowed?

Plain-English Example

Think of Google Docs permissions. You're not just a "document editor" (role) — you need permission to edit each specific document. Your friend shares Document A with you (resource-level grant), but that doesn't give you access to Document B.

How It Works

When rendering UI or allowing actions, you check the resource itself:

// Not just: canEdit = user.role === 'editor'
// But: canEdit = checkPermission(user, 'edit', post)

Your permission data structure might include resource IDs:

permissions: {
  'post:123': ['read', 'edit'],
  'post:456': ['read']
}

Key Takeaway: Resource-level permissions check access to specific data items, enabling fine-grained authorization like "you can edit your posts, but only view others' posts."