Signed Glide URLs return 400 when the site URL is on a different domain from the app
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #15515 của @lazerg — đã đóng, không merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with GlideController::validateSignature(), where the issue identifies the URL-path calculation. Check how its existing tests cover signature validation, then add regression coverage for a site URL on a different domain and for a site URL with a path prefix. Done means both cases validate signed Glide URLs correctly; an open linked pull request indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug description
With image_manipulation.secure enabled, every Glide request returns 400 Signature is not valid. if the site's url in sites.yaml is on a different domain from the one serving Statamic.
We hit this running Statamic headless. The site URLs point at our frontend (https://www.example.com) so entry URLs come out right, while Statamic and its /img route are on https://cms.example.com.
GlideController::validateSignature() works out the path to check like this:
$path = Str::after($this->request->url(), Site::current()->absoluteUrl());
For a request to https://cms.example.com/img/..., the site URL is https://www.example.com. That isn't part of the request URL, so Str::after() returns the whole URL. The signature was generated over /img/..., so it never matches.
One possible fix is to fall back to the request path when the site URL isn't a prefix of the request URL:
$url = $this->request->url();
$siteUrl = Site::current()->absoluteUrl();
$path = Str::startsWith($url, $siteUrl)
? Str::after($url, $siteUrl)
: $this->request->getPathInfo();
Sites with a path prefix (/de/img/...) still take the first branch, so their URLs keep working. Using getPathInfo() on its own would break them.
How to reproduce
- Set a site's
urlinresources/sites.yamlto a different domain from the app, for examplehttps://www.example.comwhile the app runs onhttp://localhost. - Leave
statamic.assets.image_manipulation.secureat its default oftrue. - Generate a URL with
Image::manipulate('image.jpg', ['w' => 300]). It comes back relative, as/img/image.jpg?w=300&s=.... - Request it from the app:
http://localhost/img/image.jpg?w=300&s=.... The response is400 Signature is not valid.
If you change the site URL to http://localhost, the same URL passes the signature check.
Logs
N/A
Environment
Statamic 6.33.0, league/glide 4.1.0, PHP 8.5.0, Laravel 13.32.0. The same line is still in GlideController in 6.34.0.
Installation
Existing Laravel app
Additional details
My colleague Andrius Gluzeckis found this.
- Ngôn ngữ chính
- PHP
- Star
- 4.9k
- Fork
- 647
- Merge trung bình
- 1 ngày 45 phút
- Pull request đã merge (30 ngày)
- 221
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của statamic/cms
-
forms ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
antlers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Nav: link to the site root with an anchor (/#section) gets is_parent on every pageCó thể đã có người làm @duncanmcclean đã nhận hôm nay. Đang mởnavigations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Multiple Choice and Checkboxes no longer offer "Inline", but the default views still use itCó thể đã có người làm @duncanmcclean đã nhận hôm nay. Đang mởforms
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Selection on a line without a docblock tag drops trailing characters (data provider attribute)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vimeo/psalm#15150 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
taskforcesh/bullmq#5238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itCó thể đã có người làm @bfs2021 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Automattic/jetpack#55517 ·
Maintainer thường phản hồi trong vòng 1 ngày