README's Laravel/Symfony request examples pass header value arrays; verifyAppHomeReq and verifyWebhookReq throw TypeError
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- php
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PHP
- 星标
- 62
- 派生
- 5
- 平均合并
- 4 小时 39 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Shopify/shopify-app-php 的其他 Issue
-
devtools-gardener
难度 3/5 半天 新手友好度 25/100
Shopify/shopify-app-php#29 ·
-
devtools-gardener
难度 5/5 一周以上 新手友好度 25/100
Shopify/shopify-app-php#25 · 2 条评论 ·
查看 Shopify/shopify-app-php 的全部 Issue
相似的 Issue
-
Upgrade psalm未关闭dependencies
难度 2/5 1-3 小时 新手友好度 66/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 66/100
mailcow/mailcow-dockerized#7705 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
pantheon-systems/wp-saml-auth#523 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
librespeed/speedtest#880 ·