{"action":"created","comment":{"url":"https://api.github.com/repos/talis/persona-php-client/pulls/comments/29239309","id":29239309,"diff_hunk":"@@ -334,6 +334,110 @@ public function getUserByGuids($guids, $token)\n         }\n     }\n \n+    /**\n+     * Require authentication on your route\n+     * @param string $sso\n+     * @param string $provider\n+     * @param string $statePrefix\n+     * @param string $appId\n+     * @access public\n+     * @return void\n+     */\n+    public function requireAuth($sso, $provider, $statePrefix, $appId)\n+    {\n+        $_SESSION['loginSSO'] = $sso;","path":"src/personaclient/PersonaClient.php","position":15,"original_position":15,"commit_id":"6d1ea16c5da0bf3f174a078fc5ddf2f6f878620e","original_commit_id":"6d1ea16c5da0bf3f174a078fc5ddf2f6f878620e","user":{"login":"rgubby","id":5399177,"avatar_url":"https://avatars.githubusercontent.com/u/5399177?v=3","gravatar_id":"","url":"https://api.github.com/users/rgubby","html_url":"https://github.com/rgubby","followers_url":"https://api.github.com/users/rgubby/followers","following_url":"https://api.github.com/users/rgubby/following{/other_user}","gists_url":"https://api.github.com/users/rgubby/gists{/gist_id}","starred_url":"https://api.github.com/users/rgubby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgubby/subscriptions","organizations_url":"https://api.github.com/users/rgubby/orgs","repos_url":"https://api.github.com/users/rgubby/repos","events_url":"https://api.github.com/users/rgubby/events{/privacy}","received_events_url":"https://api.github.com/users/rgubby/received_events","type":"User","site_admin":false},"body":"Probably not!","created_at":"2015-04-28T13:01:25Z","updated_at":"2015-04-28T13:01:25Z","html_url":"https://github.com/talis/persona-php-client/pull/8#discussion_r29239309","pull_request_url":"https://api.github.com/repos/talis/persona-php-client/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/comments/29239309"},"html":{"href":"https://github.com/talis/persona-php-client/pull/8#discussion_r29239309"},"pull_request":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/talis/persona-php-client/pulls/8","id":34263509,"html_url":"https://github.com/talis/persona-php-client/pull/8","diff_url":"https://github.com/talis/persona-php-client/pull/8.diff","patch_url":"https://github.com/talis/persona-php-client/pull/8.patch","issue_url":"https://api.github.com/repos/talis/persona-php-client/issues/8","number":8,"state":"open","locked":false,"title":"First stab at user authentication","user":{"login":"rgubby","id":5399177,"avatar_url":"https://avatars.githubusercontent.com/u/5399177?v=3","gravatar_id":"","url":"https://api.github.com/users/rgubby","html_url":"https://github.com/rgubby","followers_url":"https://api.github.com/users/rgubby/followers","following_url":"https://api.github.com/users/rgubby/following{/other_user}","gists_url":"https://api.github.com/users/rgubby/gists{/gist_id}","starred_url":"https://api.github.com/users/rgubby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgubby/subscriptions","organizations_url":"https://api.github.com/users/rgubby/orgs","repos_url":"https://api.github.com/users/rgubby/repos","events_url":"https://api.github.com/users/rgubby/events{/privacy}","received_events_url":"https://api.github.com/users/rgubby/received_events","type":"User","site_admin":false},"body":"This PR is so that on a server-side app, you can drop functionality right in and it'll handle all authentication for you.\r\n\r\n## Workflow\r\n\r\n### Step 0: Register your application with Persona - give it a callback URL - you'll need to remember the app ID (see step 1)\r\n\r\n### Step 1: Add the following to your app to authenticate a route:\r\n```\r\n$persona->requireAuth('http://persona/auth/providers/google/login', 'google', 'broadminster', '987');\r\n```\r\nWhere the first param is the SSO URL, the 2nd is the login provider name, the 3rd is a \"state prefix\" - which is dropped onto the start of the state value (used for combating CSRF), the 4th param is an app ID.\r\n\r\n### Step 2:  On the callback URL on the calling app, authenticate the request:\r\n```\r\nif($persona->authenticate())\r\n{\r\n    $statePrefix = $persona->getPayloadValue('statePrefix');\r\n    $persistentId = $persona->getPersistentId();\r\n    $redirect = $persona->getPayloadValue('redirect');\r\n}\r\n```\r\n\r\nThe ```authenticate``` function checks that the state param you sent when doing a login request matches what comes back - instead of doing it in your app yourself.\r\n\r\n```getPayloadValue``` will return a value set in the payload back in the route and ```getPersistentId``` will return a user ID based off the relevant entry in ```gupid``` (also from the payload).\r\n\r\n## Todo\r\n* ```isLoggedIn``` checks that the token you have is valid. If it is then all is well with the world - but if not, then it needs to obtain a new one.","created_at":"2015-04-28T12:56:53Z","updated_at":"2015-04-28T13:01:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"732c001a697feb5bc520a86ff0f2dadb00392561","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/talis/persona-php-client/pulls/8/commits","review_comments_url":"https://api.github.com/repos/talis/persona-php-client/pulls/8/comments","review_comment_url":"https://api.github.com/repos/talis/persona-php-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/talis/persona-php-client/issues/8/comments","statuses_url":"https://api.github.com/repos/talis/persona-php-client/statuses/6d1ea16c5da0bf3f174a078fc5ddf2f6f878620e","head":{"label":"talis:add-login-flow","ref":"add-login-flow","sha":"6d1ea16c5da0bf3f174a078fc5ddf2f6f878620e","user":{"login":"talis","id":181416,"avatar_url":"https://avatars.githubusercontent.com/u/181416?v=3","gravatar_id":"","url":"https://api.github.com/users/talis","html_url":"https://github.com/talis","followers_url":"https://api.github.com/users/talis/followers","following_url":"https://api.github.com/users/talis/following{/other_user}","gists_url":"https://api.github.com/users/talis/gists{/gist_id}","starred_url":"https://api.github.com/users/talis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talis/subscriptions","organizations_url":"https://api.github.com/users/talis/orgs","repos_url":"https://api.github.com/users/talis/repos","events_url":"https://api.github.com/users/talis/events{/privacy}","received_events_url":"https://api.github.com/users/talis/received_events","type":"Organization","site_admin":false},"repo":{"id":16688350,"name":"persona-php-client","full_name":"talis/persona-php-client","owner":{"login":"talis","id":181416,"avatar_url":"https://avatars.githubusercontent.com/u/181416?v=3","gravatar_id":"","url":"https://api.github.com/users/talis","html_url":"https://github.com/talis","followers_url":"https://api.github.com/users/talis/followers","following_url":"https://api.github.com/users/talis/following{/other_user}","gists_url":"https://api.github.com/users/talis/gists{/gist_id}","starred_url":"https://api.github.com/users/talis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talis/subscriptions","organizations_url":"https://api.github.com/users/talis/orgs","repos_url":"https://api.github.com/users/talis/repos","events_url":"https://api.github.com/users/talis/events{/privacy}","received_events_url":"https://api.github.com/users/talis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/talis/persona-php-client","description":"This is a php client library for Persona supporting generation, validation and caching of Oauth Tokens","fork":false,"url":"https://api.github.com/repos/talis/persona-php-client","forks_url":"https://api.github.com/repos/talis/persona-php-client/forks","keys_url":"https://api.github.com/repos/talis/persona-php-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/talis/persona-php-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/talis/persona-php-client/teams","hooks_url":"https://api.github.com/repos/talis/persona-php-client/hooks","issue_events_url":"https://api.github.com/repos/talis/persona-php-client/issues/events{/number}","events_url":"https://api.github.com/repos/talis/persona-php-client/events","assignees_url":"https://api.github.com/repos/talis/persona-php-client/assignees{/user}","branches_url":"https://api.github.com/repos/talis/persona-php-client/branches{/branch}","tags_url":"https://api.github.com/repos/talis/persona-php-client/tags","blobs_url":"https://api.github.com/repos/talis/persona-php-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/talis/persona-php-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/talis/persona-php-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/talis/persona-php-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/talis/persona-php-client/statuses/{sha}","languages_url":"https://api.github.com/repos/talis/persona-php-client/languages","stargazers_url":"https://api.github.com/repos/talis/persona-php-client/stargazers","contributors_url":"https://api.github.com/repos/talis/persona-php-client/contributors","subscribers_url":"https://api.github.com/repos/talis/persona-php-client/subscribers","subscription_url":"https://api.github.com/repos/talis/persona-php-client/subscription","commits_url":"https://api.github.com/repos/talis/persona-php-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/talis/persona-php-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/talis/persona-php-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/talis/persona-php-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/talis/persona-php-client/contents/{+path}","compare_url":"https://api.github.com/repos/talis/persona-php-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/talis/persona-php-client/merges","archive_url":"https://api.github.com/repos/talis/persona-php-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/talis/persona-php-client/downloads","issues_url":"https://api.github.com/repos/talis/persona-php-client/issues{/number}","pulls_url":"https://api.github.com/repos/talis/persona-php-client/pulls{/number}","milestones_url":"https://api.github.com/repos/talis/persona-php-client/milestones{/number}","notifications_url":"https://api.github.com/repos/talis/persona-php-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/talis/persona-php-client/labels{/name}","releases_url":"https://api.github.com/repos/talis/persona-php-client/releases{/id}","created_at":"2014-02-10T07:57:51Z","updated_at":"2015-04-28T09:52:25Z","pushed_at":"2015-04-28T12:56:54Z","git_url":"git://github.com/talis/persona-php-client.git","ssh_url":"git@github.com:talis/persona-php-client.git","clone_url":"https://github.com/talis/persona-php-client.git","svn_url":"https://github.com/talis/persona-php-client","homepage":null,"size":364,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"talis:master","ref":"master","sha":"c75d76f54aafed1483b9be4debc2fb2c81365abd","user":{"login":"talis","id":181416,"avatar_url":"https://avatars.githubusercontent.com/u/181416?v=3","gravatar_id":"","url":"https://api.github.com/users/talis","html_url":"https://github.com/talis","followers_url":"https://api.github.com/users/talis/followers","following_url":"https://api.github.com/users/talis/following{/other_user}","gists_url":"https://api.github.com/users/talis/gists{/gist_id}","starred_url":"https://api.github.com/users/talis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talis/subscriptions","organizations_url":"https://api.github.com/users/talis/orgs","repos_url":"https://api.github.com/users/talis/repos","events_url":"https://api.github.com/users/talis/events{/privacy}","received_events_url":"https://api.github.com/users/talis/received_events","type":"Organization","site_admin":false},"repo":{"id":16688350,"name":"persona-php-client","full_name":"talis/persona-php-client","owner":{"login":"talis","id":181416,"avatar_url":"https://avatars.githubusercontent.com/u/181416?v=3","gravatar_id":"","url":"https://api.github.com/users/talis","html_url":"https://github.com/talis","followers_url":"https://api.github.com/users/talis/followers","following_url":"https://api.github.com/users/talis/following{/other_user}","gists_url":"https://api.github.com/users/talis/gists{/gist_id}","starred_url":"https://api.github.com/users/talis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talis/subscriptions","organizations_url":"https://api.github.com/users/talis/orgs","repos_url":"https://api.github.com/users/talis/repos","events_url":"https://api.github.com/users/talis/events{/privacy}","received_events_url":"https://api.github.com/users/talis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/talis/persona-php-client","description":"This is a php client library for Persona supporting generation, validation and caching of Oauth Tokens","fork":false,"url":"https://api.github.com/repos/talis/persona-php-client","forks_url":"https://api.github.com/repos/talis/persona-php-client/forks","keys_url":"https://api.github.com/repos/talis/persona-php-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/talis/persona-php-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/talis/persona-php-client/teams","hooks_url":"https://api.github.com/repos/talis/persona-php-client/hooks","issue_events_url":"https://api.github.com/repos/talis/persona-php-client/issues/events{/number}","events_url":"https://api.github.com/repos/talis/persona-php-client/events","assignees_url":"https://api.github.com/repos/talis/persona-php-client/assignees{/user}","branches_url":"https://api.github.com/repos/talis/persona-php-client/branches{/branch}","tags_url":"https://api.github.com/repos/talis/persona-php-client/tags","blobs_url":"https://api.github.com/repos/talis/persona-php-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/talis/persona-php-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/talis/persona-php-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/talis/persona-php-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/talis/persona-php-client/statuses/{sha}","languages_url":"https://api.github.com/repos/talis/persona-php-client/languages","stargazers_url":"https://api.github.com/repos/talis/persona-php-client/stargazers","contributors_url":"https://api.github.com/repos/talis/persona-php-client/contributors","subscribers_url":"https://api.github.com/repos/talis/persona-php-client/subscribers","subscription_url":"https://api.github.com/repos/talis/persona-php-client/subscription","commits_url":"https://api.github.com/repos/talis/persona-php-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/talis/persona-php-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/talis/persona-php-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/talis/persona-php-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/talis/persona-php-client/contents/{+path}","compare_url":"https://api.github.com/repos/talis/persona-php-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/talis/persona-php-client/merges","archive_url":"https://api.github.com/repos/talis/persona-php-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/talis/persona-php-client/downloads","issues_url":"https://api.github.com/repos/talis/persona-php-client/issues{/number}","pulls_url":"https://api.github.com/repos/talis/persona-php-client/pulls{/number}","milestones_url":"https://api.github.com/repos/talis/persona-php-client/milestones{/number}","notifications_url":"https://api.github.com/repos/talis/persona-php-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/talis/persona-php-client/labels{/name}","releases_url":"https://api.github.com/repos/talis/persona-php-client/releases{/id}","created_at":"2014-02-10T07:57:51Z","updated_at":"2015-04-28T09:52:25Z","pushed_at":"2015-04-28T12:56:54Z","git_url":"git://github.com/talis/persona-php-client.git","ssh_url":"git@github.com:talis/persona-php-client.git","clone_url":"https://github.com/talis/persona-php-client.git","svn_url":"https://github.com/talis/persona-php-client","homepage":null,"size":364,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/8"},"html":{"href":"https://github.com/talis/persona-php-client/pull/8"},"issue":{"href":"https://api.github.com/repos/talis/persona-php-client/issues/8"},"comments":{"href":"https://api.github.com/repos/talis/persona-php-client/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/talis/persona-php-client/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/talis/persona-php-client/statuses/6d1ea16c5da0bf3f174a078fc5ddf2f6f878620e"}}}}