README's Laravel/Symfony request examples pass header value arrays; verifyAppHomeReq and verifyWebhookReq throw TypeError
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- php
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Read Headers::normalize() and the verifier paths in src/Internal/Verify/AppHomeReq.php and src/Internal/Verify/BodyHmacInHeader.php; compare their expected header values with the arrays returned by Laravel and Symfony. Check how AdminUIExt, PosUIExt, and NonExchangeableIdToken use Authorization headers. Reproduce both reported TypeErrors, then verify that array-valued headers are handled and scalar headers still produce the expected results.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The "Converting a request" section of the README shows Laravel and Symfony examples that build the request array with $request->headers->all(). Symfony's HeaderBag::all() (which Laravel's request uses too) returns ['name' => ['value', …]], one list of values per header. Headers::normalize() only lowercases the keys, so the verifiers receive arrays where they expect strings:
verifyAppHomeReqwith anAuthorization: Bearer …header (every App Bridgefetch()) throwsTypeError: strpos(): Argument #1 ($haystack) must be of type string, array givenatsrc/Internal/Verify/AppHomeReq.php:182.verifyWebhookReqwith a correctly signed webhook throwsTypeError: hash_equals(): Argument #2 ($user_string) must be of type string, array giveninsrc/Internal/Verify/BodyHmacInHeader.php.
The initial page request works because its ID token is in the query string, so an app that follows the README sees this on its first API call or its first webhook. AdminUIExt, PosUIExt and NonExchangeableIdToken read the Authorization header the same way.
Reproduction with the package alone, v1.0.2 on PHP 8.5 (the same code is on main as of 9 Oct 2026):
$app = new Shopify\App\ShopifyApp(
clientId: 'test-client-id',
clientSecret: 'test-client-secret-at-least-32-bytes-long',
);
$app->verifyAppHomeReq([
'method' => 'GET',
'headers' => ['authorization' => ['Bearer x.y.z']],
'url' => 'https://example.test/api/shop',
'body' => '',
], appHomePatchIdTokenPath: '/auth/patch-id-token');
// TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given
$body = '{"domain":"test-shop.myshopify.com"}';
$hmac = base64_encode(hash_hmac('sha256', $body, 'test-client-secret-at-least-32-bytes-long', true));
$app->verifyWebhookReq([
'method' => 'POST',
'headers' => ['x-shopify-hmac-sha256' => [$hmac], 'x-shopify-shop-domain' => ['test-shop.myshopify.com']],
'url' => 'https://example.test/api/webhooks',
'body' => $body,
]);
// TypeError: hash_equals(): Argument #2 ($user_string) must be of type string, array given
With string values both calls behave normally (invalid_id_token for the fake token, verified for the webhook).
Two possible fixes: change the README examples to join the values, e.g. array_map(fn ($v) => implode(', ', $v), $request->headers->all()); or have Headers::normalize() accept arrays and join them, which would also cover other frameworks that return value lists. Happy to open a PR for either.
- Ngôn ngữ chính
- PHP
- Star
- 62
- Fork
- 5
- Merge trung bình
- 4 giờ 39 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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 Shopify/shopify-app-php
-
Is storefront API missing?Đang mởdevtools-gardener
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 25/100
Shopify/shopify-app-php#29 ·
-
devtools-gardener
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Shopify/shopify-app-php#25 · 2 bình luận ·
Tất cả issue của Shopify/shopify-app-php
Issue tương tự
-
Upgrade psalmĐang mởdependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Update SOGo to v5.12.14Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
mailcow/mailcow-dockerized#7705 ·
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 66/100
pantheon-systems/wp-saml-auth#523 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
librespeed/speedtest#880 ·