From 2b912c7afb73858671782fb3e2f4f86d59804389 Mon Sep 17 00:00:00 2001 From: andrewscofield Date: Mon, 23 Mar 2020 15:02:29 -0500 Subject: [PATCH 1/3] Only process needed request values I was getting a PHP compile error on `implode` because I was sending other data through the an API route. Meaning I had payload data in my request and this function was not processing it correctly. --- src/ShopifyApp/Http/Middleware/AuthShopify.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ShopifyApp/Http/Middleware/AuthShopify.php b/src/ShopifyApp/Http/Middleware/AuthShopify.php index a40f6ad1..5e3ec0e6 100644 --- a/src/ShopifyApp/Http/Middleware/AuthShopify.php +++ b/src/ShopifyApp/Http/Middleware/AuthShopify.php @@ -236,9 +236,12 @@ private function getData(Request $request, string $source): array // GET/POST DataSource::INPUT()->toNative() => function () use ($request): array { // Verify + $shopify_values = array('shop', 'hmac', 'timestamp', 'timestamp'); $verify = []; foreach ($request->all() as $key => $value) { - $verify[$key] = is_array($value) ? '["'.implode('", "', $value).'"]' : $value; + if(in_array($key, $shopify_values)) { + $verify[$key] = is_array($value) ? '["'.implode('", "', $value).'"]' : $value; + } } return $verify; From bfa6a6f5bb3a2e7e94036441a0826985f5ddce8c Mon Sep 17 00:00:00 2001 From: andrewscofield Date: Mon, 23 Mar 2020 15:08:26 -0500 Subject: [PATCH 2/3] php style fix --- src/ShopifyApp/Http/Middleware/AuthShopify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ShopifyApp/Http/Middleware/AuthShopify.php b/src/ShopifyApp/Http/Middleware/AuthShopify.php index 5e3ec0e6..334cb096 100644 --- a/src/ShopifyApp/Http/Middleware/AuthShopify.php +++ b/src/ShopifyApp/Http/Middleware/AuthShopify.php @@ -239,7 +239,7 @@ private function getData(Request $request, string $source): array $shopify_values = array('shop', 'hmac', 'timestamp', 'timestamp'); $verify = []; foreach ($request->all() as $key => $value) { - if(in_array($key, $shopify_values)) { + if (in_array($key, $shopify_values)) { $verify[$key] = is_array($value) ? '["'.implode('", "', $value).'"]' : $value; } } From 1d32c1338c339f307cb5e20569a8d18760e4f059 Mon Sep 17 00:00:00 2001 From: andrewscofield Date: Wed, 1 Apr 2020 20:17:18 -0500 Subject: [PATCH 3/3] Change to use query() --- src/ShopifyApp/Http/Middleware/AuthShopify.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ShopifyApp/Http/Middleware/AuthShopify.php b/src/ShopifyApp/Http/Middleware/AuthShopify.php index 334cb096..ead9758d 100644 --- a/src/ShopifyApp/Http/Middleware/AuthShopify.php +++ b/src/ShopifyApp/Http/Middleware/AuthShopify.php @@ -236,12 +236,9 @@ private function getData(Request $request, string $source): array // GET/POST DataSource::INPUT()->toNative() => function () use ($request): array { // Verify - $shopify_values = array('shop', 'hmac', 'timestamp', 'timestamp'); $verify = []; - foreach ($request->all() as $key => $value) { - if (in_array($key, $shopify_values)) { - $verify[$key] = is_array($value) ? '["'.implode('", "', $value).'"]' : $value; - } + foreach ($request->query() as $key => $value) { + $verify[$key] = is_array($value) ? '["'.implode('", "', $value).'"]' : $value; } return $verify;