{"action":"created","comment":{"url":"https://api.github.com/repos/piwik/piwik/pulls/comments/89028965","pull_request_review_id":9581645,"id":89028965,"diff_hunk":"@@ -780,16 +805,41 @@ private function isUserTheOnlyUserHavingSuperUserAccess($userLogin)\n     }\n \n     /**\n+     * Generates a new random authentication token.\n+     *\n+     * @param string $userLogin Login\n+     * @return string\n+     */\n+    public function createTokenAuth($userLogin)\n+    {\n+        return hash(\n+            'sha256',\n+            $userLogin . microtime(true) . Common::generateUniqId() . SettingsPiwik::getSalt()\n+        );\n+    }\n+\n+    /**\n      * Generates a unique MD5 for the given login & password\n      *\n      * @param string $userLogin Login\n      * @param string $md5Password hashed string of the password (using current hash function; MD5-named for historical reasons)\n      * @return string\n+     * @throws Exception if credentials do not match\n      */\n     public function getTokenAuth($userLogin, $md5Password)\n     {\n         UsersManager::checkPasswordHash($md5Password, Piwik::translate('UsersManager_ExceptionPasswordMD5HashExpected'));\n \n-        return md5($userLogin . $md5Password);\n+        $user = $this->model->getUser($userLogin);\n+\n+        if (!empty($user) && password_verify($md5Password, $user['password'])) {\n+            if (password_needs_rehash($user['password'], PASSWORD_BCRYPT)) {\n+                $this->model->updateUser($login, $md5Password, $user['alias'], $user['email'], $user['token_auth']);\n+            }\n+\n+            return $user['token_auth'];\n+        }\n+\n+        throw new Exception(Piwik::translate('UsersManager_ExceptionTokenAuthCredentials', $userLogin));","path":"plugins/UsersManager/API.php","position":114,"original_position":114,"commit_id":"a9d76c02a5c1d35981051e66dc87acb4ba33d3b6","original_commit_id":"a9d76c02a5c1d35981051e66dc87acb4ba33d3b6","user":{"login":"mattab","id":466765,"avatar_url":"https://avatars.githubusercontent.com/u/466765?v=3","gravatar_id":"","url":"https://api.github.com/users/mattab","html_url":"https://github.com/mattab","followers_url":"https://api.github.com/users/mattab/followers","following_url":"https://api.github.com/users/mattab/following{/other_user}","gists_url":"https://api.github.com/users/mattab/gists{/gist_id}","starred_url":"https://api.github.com/users/mattab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattab/subscriptions","organizations_url":"https://api.github.com/users/mattab/orgs","repos_url":"https://api.github.com/users/mattab/repos","events_url":"https://api.github.com/users/mattab/events{/privacy}","received_events_url":"https://api.github.com/users/mattab/received_events","type":"User","site_admin":false},"body":":+1: `UsersManager.getTokenAuth` is one of these APIs that many users rely on, and it would be great from a API user experience perspective to maintain BC","created_at":"2016-11-22T01:44:45Z","updated_at":"2016-11-22T01:44:45Z","html_url":"https://github.com/piwik/piwik/pull/10740#discussion_r89028965","pull_request_url":"https://api.github.com/repos/piwik/piwik/pulls/10740","_links":{"self":{"href":"https://api.github.com/repos/piwik/piwik/pulls/comments/89028965"},"html":{"href":"https://github.com/piwik/piwik/pull/10740#discussion_r89028965"},"pull_request":{"href":"https://api.github.com/repos/piwik/piwik/pulls/10740"}}},"pull_request":{"url":"https://api.github.com/repos/piwik/piwik/pulls/10740","id":89435814,"html_url":"https://github.com/piwik/piwik/pull/10740","diff_url":"https://github.com/piwik/piwik/pull/10740.diff","patch_url":"https://github.com/piwik/piwik/pull/10740.patch","issue_url":"https://api.github.com/repos/piwik/piwik/issues/10740","number":10740,"state":"open","locked":false,"title":"[WIP] Updates password/token_auth hashing","user":{"login":"mneudert","id":635801,"avatar_url":"https://avatars.githubusercontent.com/u/635801?v=3","gravatar_id":"","url":"https://api.github.com/users/mneudert","html_url":"https://github.com/mneudert","followers_url":"https://api.github.com/users/mneudert/followers","following_url":"https://api.github.com/users/mneudert/following{/other_user}","gists_url":"https://api.github.com/users/mneudert/gists{/gist_id}","starred_url":"https://api.github.com/users/mneudert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mneudert/subscriptions","organizations_url":"https://api.github.com/users/mneudert/orgs","repos_url":"https://api.github.com/users/mneudert/repos","events_url":"https://api.github.com/users/mneudert/events{/privacy}","received_events_url":"https://api.github.com/users/mneudert/received_events","type":"User","site_admin":false},"body":"Refs #5728:\n- Updates password hashing\n- Updates token_auth hashing\n\nwork in progress...\n","created_at":"2016-10-14T18:52:38Z","updated_at":"2016-11-22T01:44:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f50ebda933c6f55e1e3dd2c9a53dd814c5f983b","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/piwik/piwik/milestones/100","html_url":"https://github.com/piwik/piwik/milestones/3.0.0-b4","labels_url":"https://api.github.com/repos/piwik/piwik/milestones/100/labels","id":2128420,"number":100,"title":"3.0.0-b4","description":null,"creator":{"login":"mattab","id":466765,"avatar_url":"https://avatars.githubusercontent.com/u/466765?v=3","gravatar_id":"","url":"https://api.github.com/users/mattab","html_url":"https://github.com/mattab","followers_url":"https://api.github.com/users/mattab/followers","following_url":"https://api.github.com/users/mattab/following{/other_user}","gists_url":"https://api.github.com/users/mattab/gists{/gist_id}","starred_url":"https://api.github.com/users/mattab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattab/subscriptions","organizations_url":"https://api.github.com/users/mattab/orgs","repos_url":"https://api.github.com/users/mattab/repos","events_url":"https://api.github.com/users/mattab/events{/privacy}","received_events_url":"https://api.github.com/users/mattab/received_events","type":"User","site_admin":false},"open_issues":43,"closed_issues":5,"state":"open","created_at":"2016-11-11T00:52:49Z","updated_at":"2016-11-21T11:07:18Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/piwik/piwik/pulls/10740/commits","review_comments_url":"https://api.github.com/repos/piwik/piwik/pulls/10740/comments","review_comment_url":"https://api.github.com/repos/piwik/piwik/pulls/comments{/number}","comments_url":"https://api.github.com/repos/piwik/piwik/issues/10740/comments","statuses_url":"https://api.github.com/repos/piwik/piwik/statuses/a9d76c02a5c1d35981051e66dc87acb4ba33d3b6","head":{"label":"mneudert:issue-5728","ref":"issue-5728","sha":"a9d76c02a5c1d35981051e66dc87acb4ba33d3b6","user":{"login":"mneudert","id":635801,"avatar_url":"https://avatars.githubusercontent.com/u/635801?v=3","gravatar_id":"","url":"https://api.github.com/users/mneudert","html_url":"https://github.com/mneudert","followers_url":"https://api.github.com/users/mneudert/followers","following_url":"https://api.github.com/users/mneudert/following{/other_user}","gists_url":"https://api.github.com/users/mneudert/gists{/gist_id}","starred_url":"https://api.github.com/users/mneudert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mneudert/subscriptions","organizations_url":"https://api.github.com/users/mneudert/orgs","repos_url":"https://api.github.com/users/mneudert/repos","events_url":"https://api.github.com/users/mneudert/events{/privacy}","received_events_url":"https://api.github.com/users/mneudert/received_events","type":"User","site_admin":false},"repo":{"id":68142665,"name":"piwik","full_name":"mneudert/piwik","owner":{"login":"mneudert","id":635801,"avatar_url":"https://avatars.githubusercontent.com/u/635801?v=3","gravatar_id":"","url":"https://api.github.com/users/mneudert","html_url":"https://github.com/mneudert","followers_url":"https://api.github.com/users/mneudert/followers","following_url":"https://api.github.com/users/mneudert/following{/other_user}","gists_url":"https://api.github.com/users/mneudert/gists{/gist_id}","starred_url":"https://api.github.com/users/mneudert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mneudert/subscriptions","organizations_url":"https://api.github.com/users/mneudert/orgs","repos_url":"https://api.github.com/users/mneudert/repos","events_url":"https://api.github.com/users/mneudert/events{/privacy}","received_events_url":"https://api.github.com/users/mneudert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mneudert/piwik","description":"Liberating Web Analytics. Star us on Github? +1. Piwik is the leading open alternative to Google Analytics that gives you full control over your data. Piwik lets you easily collect data from websites, apps & the IoT and visualise this data and extract insights. Privacy is built-in. We love Pull Requests! ","fork":true,"url":"https://api.github.com/repos/mneudert/piwik","forks_url":"https://api.github.com/repos/mneudert/piwik/forks","keys_url":"https://api.github.com/repos/mneudert/piwik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mneudert/piwik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mneudert/piwik/teams","hooks_url":"https://api.github.com/repos/mneudert/piwik/hooks","issue_events_url":"https://api.github.com/repos/mneudert/piwik/issues/events{/number}","events_url":"https://api.github.com/repos/mneudert/piwik/events","assignees_url":"https://api.github.com/repos/mneudert/piwik/assignees{/user}","branches_url":"https://api.github.com/repos/mneudert/piwik/branches{/branch}","tags_url":"https://api.github.com/repos/mneudert/piwik/tags","blobs_url":"https://api.github.com/repos/mneudert/piwik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mneudert/piwik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mneudert/piwik/git/refs{/sha}","trees_url":"https://api.github.com/repos/mneudert/piwik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mneudert/piwik/statuses/{sha}","languages_url":"https://api.github.com/repos/mneudert/piwik/languages","stargazers_url":"https://api.github.com/repos/mneudert/piwik/stargazers","contributors_url":"https://api.github.com/repos/mneudert/piwik/contributors","subscribers_url":"https://api.github.com/repos/mneudert/piwik/subscribers","subscription_url":"https://api.github.com/repos/mneudert/piwik/subscription","commits_url":"https://api.github.com/repos/mneudert/piwik/commits{/sha}","git_commits_url":"https://api.github.com/repos/mneudert/piwik/git/commits{/sha}","comments_url":"https://api.github.com/repos/mneudert/piwik/comments{/number}","issue_comment_url":"https://api.github.com/repos/mneudert/piwik/issues/comments{/number}","contents_url":"https://api.github.com/repos/mneudert/piwik/contents/{+path}","compare_url":"https://api.github.com/repos/mneudert/piwik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mneudert/piwik/merges","archive_url":"https://api.github.com/repos/mneudert/piwik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mneudert/piwik/downloads","issues_url":"https://api.github.com/repos/mneudert/piwik/issues{/number}","pulls_url":"https://api.github.com/repos/mneudert/piwik/pulls{/number}","milestones_url":"https://api.github.com/repos/mneudert/piwik/milestones{/number}","notifications_url":"https://api.github.com/repos/mneudert/piwik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mneudert/piwik/labels{/name}","releases_url":"https://api.github.com/repos/mneudert/piwik/releases{/id}","deployments_url":"https://api.github.com/repos/mneudert/piwik/deployments","created_at":"2016-09-13T19:59:02Z","updated_at":"2016-09-13T19:59:18Z","pushed_at":"2016-11-20T15:01:35Z","git_url":"git://github.com/mneudert/piwik.git","ssh_url":"git@github.com:mneudert/piwik.git","clone_url":"https://github.com/mneudert/piwik.git","svn_url":"https://github.com/mneudert/piwik","homepage":"http://piwik.org/","size":166476,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"piwik:3.x-dev","ref":"3.x-dev","sha":"f41820399921b4e65810e5395010d3746bba6fdd","user":{"login":"piwik","id":698038,"avatar_url":"https://avatars.githubusercontent.com/u/698038?v=3","gravatar_id":"","url":"https://api.github.com/users/piwik","html_url":"https://github.com/piwik","followers_url":"https://api.github.com/users/piwik/followers","following_url":"https://api.github.com/users/piwik/following{/other_user}","gists_url":"https://api.github.com/users/piwik/gists{/gist_id}","starred_url":"https://api.github.com/users/piwik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piwik/subscriptions","organizations_url":"https://api.github.com/users/piwik/orgs","repos_url":"https://api.github.com/users/piwik/repos","events_url":"https://api.github.com/users/piwik/events{/privacy}","received_events_url":"https://api.github.com/users/piwik/received_events","type":"Organization","site_admin":false},"repo":{"id":1548202,"name":"piwik","full_name":"piwik/piwik","owner":{"login":"piwik","id":698038,"avatar_url":"https://avatars.githubusercontent.com/u/698038?v=3","gravatar_id":"","url":"https://api.github.com/users/piwik","html_url":"https://github.com/piwik","followers_url":"https://api.github.com/users/piwik/followers","following_url":"https://api.github.com/users/piwik/following{/other_user}","gists_url":"https://api.github.com/users/piwik/gists{/gist_id}","starred_url":"https://api.github.com/users/piwik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piwik/subscriptions","organizations_url":"https://api.github.com/users/piwik/orgs","repos_url":"https://api.github.com/users/piwik/repos","events_url":"https://api.github.com/users/piwik/events{/privacy}","received_events_url":"https://api.github.com/users/piwik/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/piwik/piwik","description":"Liberating Web Analytics. Star us on Github? +1. Piwik is the leading open alternative to Google Analytics that gives you full control over your data. Piwik lets you easily collect data from websites, apps & the IoT and visualise this data and extract insights. Privacy is built-in. We love Pull Requests! ","fork":false,"url":"https://api.github.com/repos/piwik/piwik","forks_url":"https://api.github.com/repos/piwik/piwik/forks","keys_url":"https://api.github.com/repos/piwik/piwik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/piwik/piwik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/piwik/piwik/teams","hooks_url":"https://api.github.com/repos/piwik/piwik/hooks","issue_events_url":"https://api.github.com/repos/piwik/piwik/issues/events{/number}","events_url":"https://api.github.com/repos/piwik/piwik/events","assignees_url":"https://api.github.com/repos/piwik/piwik/assignees{/user}","branches_url":"https://api.github.com/repos/piwik/piwik/branches{/branch}","tags_url":"https://api.github.com/repos/piwik/piwik/tags","blobs_url":"https://api.github.com/repos/piwik/piwik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/piwik/piwik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/piwik/piwik/git/refs{/sha}","trees_url":"https://api.github.com/repos/piwik/piwik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/piwik/piwik/statuses/{sha}","languages_url":"https://api.github.com/repos/piwik/piwik/languages","stargazers_url":"https://api.github.com/repos/piwik/piwik/stargazers","contributors_url":"https://api.github.com/repos/piwik/piwik/contributors","subscribers_url":"https://api.github.com/repos/piwik/piwik/subscribers","subscription_url":"https://api.github.com/repos/piwik/piwik/subscription","commits_url":"https://api.github.com/repos/piwik/piwik/commits{/sha}","git_commits_url":"https://api.github.com/repos/piwik/piwik/git/commits{/sha}","comments_url":"https://api.github.com/repos/piwik/piwik/comments{/number}","issue_comment_url":"https://api.github.com/repos/piwik/piwik/issues/comments{/number}","contents_url":"https://api.github.com/repos/piwik/piwik/contents/{+path}","compare_url":"https://api.github.com/repos/piwik/piwik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/piwik/piwik/merges","archive_url":"https://api.github.com/repos/piwik/piwik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/piwik/piwik/downloads","issues_url":"https://api.github.com/repos/piwik/piwik/issues{/number}","pulls_url":"https://api.github.com/repos/piwik/piwik/pulls{/number}","milestones_url":"https://api.github.com/repos/piwik/piwik/milestones{/number}","notifications_url":"https://api.github.com/repos/piwik/piwik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/piwik/piwik/labels{/name}","releases_url":"https://api.github.com/repos/piwik/piwik/releases{/id}","deployments_url":"https://api.github.com/repos/piwik/piwik/deployments","created_at":"2011-03-30T21:18:17Z","updated_at":"2016-11-21T07:23:43Z","pushed_at":"2016-11-21T18:03:28Z","git_url":"git://github.com/piwik/piwik.git","ssh_url":"git@github.com:piwik/piwik.git","clone_url":"https://github.com/piwik/piwik.git","svn_url":"https://github.com/piwik/piwik","homepage":"http://piwik.org/","size":216605,"stargazers_count":6328,"watchers_count":6328,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1113,"mirror_url":null,"open_issues_count":1389,"forks":1113,"open_issues":1389,"watchers":6328,"default_branch":"3.x-dev"}},"_links":{"self":{"href":"https://api.github.com/repos/piwik/piwik/pulls/10740"},"html":{"href":"https://github.com/piwik/piwik/pull/10740"},"issue":{"href":"https://api.github.com/repos/piwik/piwik/issues/10740"},"comments":{"href":"https://api.github.com/repos/piwik/piwik/issues/10740/comments"},"review_comments":{"href":"https://api.github.com/repos/piwik/piwik/pulls/10740/comments"},"review_comment":{"href":"https://api.github.com/repos/piwik/piwik/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/piwik/piwik/pulls/10740/commits"},"statuses":{"href":"https://api.github.com/repos/piwik/piwik/statuses/a9d76c02a5c1d35981051e66dc87acb4ba33d3b6"}}}}
{"actor":{"display_login":"mattab"}}