Media Library Permissions#
The Strapi Media Library (plugin::upload) enforces access control through the standard admin RBAC system. Permissions are modeled on assets (files), not on folders ā there is no mechanism to assign permissions to individual folders . Folder operations inherit the same action UIDs used for assets.
Registered Actions#
The upload plugin registers the following permission actions at bootstrap :
| UID | Display name | Subcategory |
|---|---|---|
plugin::upload.read | Access the Media Library | ā |
plugin::upload.assets.create | Create (upload) | assets |
plugin::upload.assets.update | Update (crop, details, replace) + delete | assets |
plugin::upload.assets.download | Download | assets |
plugin::upload.assets.copy-link | Copy link | assets |
plugin::upload.configure-view | Configure view | ā |
plugin::upload.settings.read | Access the Media Library settings page | settings |
These constants are defined in constants.ts. Notably, there is no dedicated delete action ā deletion of both files and folders is gated on plugin::upload.assets.update.
Route-Level Permission Gates#
Both delete paths require the same route policy before a controller handler runs :
| Operation | Route | Route policy action |
|---|---|---|
| Single file delete | DELETE /files/:id | plugin::upload.assets.update |
| Bulk delete (files + folders) | POST /actions/bulk-delete | plugin::upload.assets.update |
The route policy (admin::hasPermissions) checks whether the authenticated admin has the action at all, without evaluating per-entity conditions such as admin::is-creator.
Per-Entity Permission Checks (Is-Creator / RBAC Conditions)#
RBAC conditions (e.g., admin::is-creator, admin::has-same-role-as-creator) filter access to individual records. They require the subject object to carry createdBy and createdBy.roles fields so the condition handler can match them against the requesting user.
Single file delete ā conditions ARE enforced#
admin-file.destroy calls findEntityAndCheckPermissions before removing the file:
- Fetches the file with
createdByandfolderpopulated . - Resolves the creator's
rolesvia a second lookup onadmin::user. - Calls
pm.ability.cannot(pm.action, pm.toSubject(fileWithRoles))ā if the condition fails (e.g., current user is not the creator), throwsForbiddenError.
This is why createdBy.roles must be eagerly populated before toSubject: missing those fields would cause a condition like is-creator to silently deny the creator's own files .
Bulk delete (folders + files) ā conditions are NOT enforced per entity#
admin-folder-file.deleteMany does not call findEntityAndCheckPermissions for each item . It:
- Validates the request body schema.
- Calls
fileService.deleteByIdsandfolderService.deleteByIdsdirectly . - Uses a permissions manager only to sanitize output, not to guard deletion .
The folder service's deleteByIds recursively deletes all descendant folders and files matching the folder's path prefix, with no per-file creator check.
Implication: An admin with assets.update but an is-creator condition attached can be blocked from deleting a single file they don't own via the single-file endpoint, yet can delete the same file (and any folder containing it) via the bulk-delete endpoint without any per-entity condition evaluation.
Key Source Files#
| File | Purpose |
|---|---|
constants.ts | Action UIDs and model UIDs |
bootstrap.ts | Registers actions with the permission system |
routes/admin.ts | Route definitions and route-level policies |
controllers/admin-file.ts | Single-file CRUD; destroy enforces per-entity conditions |
controllers/admin-folder.ts | Folder CRUD; no delete endpoint (deletion is bulk-only) |
controllers/admin-folder-file.ts | Bulk delete & move; skips per-entity condition checks |
controllers/utils/find-entity-and-check-permissions.ts | Per-entity RBAC condition evaluation helper |
services/folder.ts | deleteByIds recursively removes descendant files without condition checks |