fix(cabana): serve public image thumbnails on the admin thumb routes
The record and relation-child thumb routes now also serve the thumbnail of a public JPEG, PNG, GIF or WebP file, under the same record or pending-session scope and D-10 headers as a protected one, so the admin can preview a public image whose public URL does not load. The download routes still answer 404 for every public file, and a public non-image thumb stays 404. TestPublicImageThumb covers owner, foreign and hidden records, image types, a public row under a protected field, another admin's pending upload and the relation-child route.
This commit is contained in:
@@ -112,9 +112,9 @@ Public and protected files live in the same bucket. A protected file (`is_public
|
||||
A `type: fileupload` field on a protected relation never shows a public URL in the admin; see [Forms](../backend/forms.md#file-uploads). The admin SPA reads such a file through two authenticated admin API routes under the `backend` guard:
|
||||
|
||||
- GET `{prefix}/api/v1/{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/download` streams the original.
|
||||
- GET `{prefix}/api/v1/{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb` streams the preview thumbnail, built with `attach.File.ThumbKey`; a file that is not a JPEG, PNG, GIF or WebP image has none.
|
||||
- GET `{prefix}/api/v1/{vendor}/{plugin}/{controller}/{id}/files/{field}/{file}/thumb` streams the preview thumbnail, built with `attach.File.ThumbKey`; a file that is not a JPEG, PNG, GIF or WebP image has none. The thumb route also serves the thumbnail of a public image, with the same scope and headers, so the admin can preview a public image whose public URL does not load; see [Forms](../backend/forms.md#file-uploads).
|
||||
|
||||
Both routes look the file up with one query scoped to its record, which the controller's `pact.FormExtendQuery` must let the administrator load, or to an upload pending in the administrator's own form session (`X-Session-Key`). A file of another record, a public file and a file outside that scope all answer 404. Every response carries `X-Content-Type-Options: nosniff`, `Cache-Control: private, no-store` and `Content-Security-Policy: default-src 'none'; sandbox`. Only JPEG, PNG, GIF and WebP are served inline with their own type; any other file, an SVG included, is sent as an `application/octet-stream` attachment, so a stored file never runs script in the admin's origin.
|
||||
Both routes look the file up with one query scoped to its record, which the controller's `pact.FormExtendQuery` must let the administrator load, or to an upload pending in the administrator's own form session (`X-Session-Key`). A file of another record and a file outside that scope answer 404 on both routes, and a public file answers 404 on the download route. Every response carries `X-Content-Type-Options: nosniff`, `Cache-Control: private, no-store` and `Content-Security-Policy: default-src 'none'; sandbox`. Only JPEG, PNG, GIF and WebP are served inline with their own type; any other file, an SVG included, is sent as an `application/octet-stream` attachment, so a stored file never runs script in the admin's origin.
|
||||
|
||||
## Deleting files after commit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user