How ownership works
When a user makes an API request, Exo checks two things:- Is the user an admin? — Admins can see and modify all records
- Does the user own the record? — Non-admin users can only access records they own
Setting the owner column
If your model has auser_id column (or similar) that links records to users, tell Exo about it:
- When listing records, non-admin users only see rows where
user_idmatches their user ID - When viewing, updating, or deleting, Exo checks that
user_idmatches before allowing the action - When creating records, Exo automatically sets
user_idto the authenticated user’s ID
Admin-only resources
If you returnnull from ownerColumn (the default), only admins can access the resource. Regular users will see an empty list and get 403 Unauthorized errors for individual records.
Relationship-based ownership
Sometimes the owner isn’t a direct column on the model. For example, aTask might belong to a Project, which belongs to a User. In this case, set ownerIsRelationship to true:
$model->user to find the related user and compare their ID.
Configuring admins
By default, no users are admins. Set theis_admin callback in config/exo.php to define who has admin access:
null to disable admin checks — all users will be treated as non-admin and scoped by ownership rules.
How authorization works
When a user tries to view, update, or delete a specific record, Exo calls theauthorize method on your resource. The default logic is:
- If the user is an admin, allow the action
- If the resource has an
ownerColumn, check if the user owns the record - If neither condition is met, deny access (returns
403 Unauthorized)
authorize for custom logic: