{"action":"created","issue":{"url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/6","repository_url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk","labels_url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/6/comments","events_url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/6/events","html_url":"https://github.com/RobbyBugatti/shopify-php-sdk/issues/6","id":175209576,"number":6,"title":"validateHmac implementation missed","user":{"login":"user-az","id":21960608,"avatar_url":"https://avatars.githubusercontent.com/u/21960608?v=3","gravatar_id":"","url":"https://api.github.com/users/user-az","html_url":"https://github.com/user-az","followers_url":"https://api.github.com/users/user-az/followers","following_url":"https://api.github.com/users/user-az/following{/other_user}","gists_url":"https://api.github.com/users/user-az/gists{/gist_id}","starred_url":"https://api.github.com/users/user-az/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/user-az/subscriptions","organizations_url":"https://api.github.com/users/user-az/orgs","repos_url":"https://api.github.com/users/user-az/repos","events_url":"https://api.github.com/users/user-az/events{/privacy}","received_events_url":"https://api.github.com/users/user-az/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-06T10:10:45Z","updated_at":"2016-09-07T08:30:25Z","closed_at":null,"body":"Hi,\r\n\r\nI used composer to install library\r\n\r\n\"robby-bugatti/shopify-php-sdk\": \"^1.0\" //1.0.3\r\n\r\nI use strict mode, as shopify API Guide recomends. Trying to get access token I've got an error \"Call to undefined function validateHmac\".\r\n\r\nIt's because  the call \r\n\r\n        /** @var \\Shopify\\AccessToken $token */\r\n        $token = \\Shopify\\Auth::accessToken($nonce);\r\n\r\nin strict mode is chained into implementation\r\n\r\n    /**\r\n     * Fetch an access token\r\n     * @param string $nonce\r\n     * @return \\Shopfiy\\AccessToken\r\n     */\r\n    public static function accessToken( $nonce = NULL )\r\n    {\r\n        // Do any strict checking for our OAuth requests\r\n        if(\\Shopify\\Shopify::strict())\r\n        {\r\n            if( !self::checkNonce( $nonce ) ) throw new \\Exception(\"Strict API execution requires a nonce for Authentication requests\");\r\n            if( !\\Shopify\\Shopify::validateHmac() ) throw new Exception\\ApiException(\"Strict API execution requires a valid HMAC signature\");\r\n        }\r\n        return \\Shopify\\AccessToken::createFromCode($_GET['code']);\r\n    }\r\n\r\nand there is no any implementation of  \\Shopify\\Shopify::validateHmac().\r\n\r\nSuch a dirty thing.\r\n"},"comment":{"url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/comments/245211799","html_url":"https://github.com/RobbyBugatti/shopify-php-sdk/issues/6#issuecomment-245211799","issue_url":"https://api.github.com/repos/RobbyBugatti/shopify-php-sdk/issues/6","id":245211799,"user":{"login":"user-az","id":21960608,"avatar_url":"https://avatars.githubusercontent.com/u/21960608?v=3","gravatar_id":"","url":"https://api.github.com/users/user-az","html_url":"https://github.com/user-az","followers_url":"https://api.github.com/users/user-az/followers","following_url":"https://api.github.com/users/user-az/following{/other_user}","gists_url":"https://api.github.com/users/user-az/gists{/gist_id}","starred_url":"https://api.github.com/users/user-az/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/user-az/subscriptions","organizations_url":"https://api.github.com/users/user-az/orgs","repos_url":"https://api.github.com/users/user-az/repos","events_url":"https://api.github.com/users/user-az/events{/privacy}","received_events_url":"https://api.github.com/users/user-az/received_events","type":"User","site_admin":false},"created_at":"2016-09-07T08:30:25Z","updated_at":"2016-09-07T08:30:25Z","body":"Well, It seems composer major version for ^1.0.x (1.0.3) is broken: here it calls\r\n\r\nhttps://github.com/RobbyBugatti/shopify-php-sdk/blob/v1.0.3/lib/Auth.php\r\n\r\nand thereis no implementation here\r\n\r\nhttps://github.com/RobbyBugatti/shopify-php-sdk/blob/v1.0.3/lib/Shopify.php\r\n\r\nThis was a default installation by composer, I guess you should make 1.0.4 release, so making default composer installation to be fixed.\r\n\r\nNow I've made \r\n\r\n$ composer require robby-bugatti/shopify-php-sdk:dev-master\r\n\r\nand get the last version. I'll try it, thanks.\r\n\r\n>On a side note, the authentication mechanism does need to be refactored\r\n\r\n) I think a lot of the SDK code should be refactored. \r\n\r\nFor instance phpDocs notations tell IDE `@return SomeTypeOfObject` , but instance of splObject really is coming back from call. It slows down development process, because developers awaiting that declared interface is right and IDE gets right autocomplition of available classes/objects/methods.  Not fatal but not good at all: having to read sources, loking ugly `print_r` transitional parts, etc. There is no `@throws` sections also.\r\n\r\nAs for `nonce` and transparent storing/restoring it from session, I think it's a good idea. I suggest you should inject some implementation of  `IStorage` interface into you service. Your implementation can use php session, and other developers can implement `IStorage` interface by their own vision (db, files, redis, pigeons etc).  Less couple, much more abstract )\r\n\r\nI think also this is not best way to operate `$_GET` or any other globals inside SDK. I think this is a controller's layer. I prefer sdk takes params from controller/cli starter/test kit.\r\n\r\nOne more thing - static. SDK suppose it's singleton. I think it's better when developer can resolve with Resource Locator  or DI be it a singleton or another instance. Right now developer should bear in mind, that thereis only one instance, initialized with THIS concrete shop. So having a bunch of shops inside cli or daemon developer should care about which one of them use SDK at the moment.\r\n\r\nSo, it was just my point of view. In any case thanks for you code, it seems it works ) and this is good.\r\n\r\nThanks.\r\n\r\n"}}
{"actor":{"display_login":"user-az"}}