Why this lesson matters

Understand authorization basics and apply it in a small Laravel feature. Middleware handles request-wide checks, authentication establishes identity, sessions preserve trusted state, and authorization decides whether that identity may perform a specific action.

How to reason about it

  • For Authorization Basics, the outcome to verify is: Authentication answers who you are; policy authorization answers whether this operation is allowed.
  • In Authorization Basics, keep this failure controlled: Hiding a button is not authorization; every protected mutation must enforce the permission or policy on the server.
  • Authorization Basics practice target: Protect one route with authentication and a policy, then verify unauthenticated, forbidden and allowed cases separately.

Practical walkthrough

In the Authorization Basics walkthrough: Authentication answers who you are; policy authorization answers whether this operation is allowed.

app/Policies/OrderPolicy.phpphp
public function update(User $user, Order $order): bool
{
    return $order->user_id === $user->id;
}

Practice it yourself

Practice

Authorization Basics exercise

Protect one route with authentication and a policy, then verify unauthenticated, forbidden and allowed cases separately.

  • Record the expected result before execution
  • Test one valid path and one lesson-specific failure path
  • Explain in two lines which boundary owns the decision

Summary