{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/comments/26357284","id":26357284,"diff_hunk":"@@ -75,8 +137,21 @@ articlePagePaths.forEach((path) => {\n \t});\n });\n \n+authenticatedRoutes = [\n+\t{\n+\t\tmethod: 'GET',\n+\t\tpath: '/test',\n+\t\t// TODO: This is just an example, remove this handler logic from the routes file later\n+\t\thandler (request: Hapi.Request, reply: any) {\n+\t\t\treply(request.auth);\n+\t\t}\n+\t}\n+];\n+\n unauthenticatedRoutes = unauthenticatedRoutes.map((route) => {\n \treturn Hoek.applyToDefaults(unauthenticatedRouteConfig, route);","path":"server/routes.ts","position":110,"original_position":110,"commit_id":"9683838ae1f26715087a15f0aa36434da4820068","original_commit_id":"9683838ae1f26715087a15f0aa36434da4820068","user":{"login":"lizlux","id":201367,"avatar_url":"https://avatars.githubusercontent.com/u/201367?v=3","gravatar_id":"","url":"https://api.github.com/users/lizlux","html_url":"https://github.com/lizlux","followers_url":"https://api.github.com/users/lizlux/followers","following_url":"https://api.github.com/users/lizlux/following{/other_user}","gists_url":"https://api.github.com/users/lizlux/gists{/gist_id}","starred_url":"https://api.github.com/users/lizlux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lizlux/subscriptions","organizations_url":"https://api.github.com/users/lizlux/orgs","repos_url":"https://api.github.com/users/lizlux/repos","events_url":"https://api.github.com/users/lizlux/events{/privacy}","received_events_url":"https://api.github.com/users/lizlux/received_events","type":"User","site_admin":false},"body":"Are we trying to name these local variables after the module that gets imported? So for example, this `Hoek` should actually be defined as `hoek`?","created_at":"2015-03-13T00:29:57Z","updated_at":"2015-03-13T00:29:57Z","html_url":"https://github.com/Wikia/mercury/pull/592#discussion_r26357284","pull_request_url":"https://api.github.com/repos/Wikia/mercury/pulls/592","_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments/26357284"},"html":{"href":"https://github.com/Wikia/mercury/pull/592#discussion_r26357284"},"pull_request":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/592"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/mercury/pulls/592","id":30523798,"html_url":"https://github.com/Wikia/mercury/pull/592","diff_url":"https://github.com/Wikia/mercury/pull/592.diff","patch_url":"https://github.com/Wikia/mercury/pull/592.patch","issue_url":"https://api.github.com/repos/Wikia/mercury/issues/592","number":592,"state":"open","locked":false,"title":"Global Authentication (built in Hapi)","user":{"login":"kenkouot","id":2964310,"avatar_url":"https://avatars.githubusercontent.com/u/2964310?v=3","gravatar_id":"","url":"https://api.github.com/users/kenkouot","html_url":"https://github.com/kenkouot","followers_url":"https://api.github.com/users/kenkouot/followers","following_url":"https://api.github.com/users/kenkouot/following{/other_user}","gists_url":"https://api.github.com/users/kenkouot/gists{/gist_id}","starred_url":"https://api.github.com/users/kenkouot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenkouot/subscriptions","organizations_url":"https://api.github.com/users/kenkouot/orgs","repos_url":"https://api.github.com/users/kenkouot/repos","events_url":"https://api.github.com/users/kenkouot/events{/privacy}","received_events_url":"https://api.github.com/users/kenkouot/received_events","type":"User","site_admin":false},"body":"Alrighty, so this is foundational work for the new global login page that the social team is doing. This PR provides a global login page that will validate your credentials with Helios and redirect to a route `/auth` implemented in your application. The `/auth` route allows your respective app to handle the credentials however you want (set your session handling, etc..,)\r\n\r\n## Sample Flow\r\nFor instance, take this (hypothetical) flow in Mercury:\r\n\r\n1. Start with an unauthenticated user\r\n2. User attempts to access `//muppet.wikia.com/wiki/Elmo/edit` on Mercury *(VCL logic puts this user in Mercury test group, so requests get routed to Mercury backends)*\r\n2. Application redirects to `//www.wikia.com/login?redirect=muppet.wikia.com/wiki/Elmo/edit` (New feature) and is served `/login` by Mercury\r\n3. User provides credentials through log in form, hits submit\r\n4. Mercury gets the POST, successfully grabs credentials from Helios\r\n5. Mercury calls a redirect to `/auth?user_id=26153217&access_token=SOME_ACCESS_TOKEN&refresh_token=SOME_REFRESH_TOKEN&redirect=muppet.wikia.com/wiki/Elmo/edit\"`\r\n6. Mercury's own implementation of `/auth` actually uses these credentials to set a session in cookie, and then redirects the user to the URI specified in the `redirect` param.\r\n\r\nYour auth route, implemented in your app (which maybe the MW/Wikia stack or Mercury, or whatever other backends we may route to) should expect to handle the following params:\r\n```json\r\n{\r\n  \"access_token\": \"...\",\r\n  \"refresh_token\": \"...\",\r\n  \"redirect\": \"...\",\r\n  \"remember\": \"...\"\r\n}\r\n```\r\nIt is up to your application afterwards to implement following the supplied redirect. You can also post from AJAX to `/login` and your response will be a JSON object with the `authRedirect` property and the same URL from step 6 as the value.\r\n## CSRF Protection\r\nThis PR also adds CSRF protection by default in our hapi routes. AJAX requests to `/login' will also need to provide a CSRF token as part of their request payload.\r\n\r\n## Special Notes\r\n* Helios config is stored in localSettings, which is .gitignore'd, please do not store any sensitive data in app code.\r\n\r\n### Remaining Tasks\r\n* [x] Add CSRF protection using [Crumb](https://github.com/hapijs/crumb)\r\n* [x] Document new routes and expectations for referring clients\r\n* [ ] Normalize error states sent from server to client for login page\r\n* [x] Implement \"Remember Me\"\r\n* [ ] Logout route should call Helios invalidation\r\n* [ ] Add meaningful validate function (validate token through Helios?)\r\n","created_at":"2015-03-05T01:57:56Z","updated_at":"2015-03-13T00:29:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02eea8389da7410f03659b5636d57c76e0e994e5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/mercury/pulls/592/commits","review_comments_url":"https://api.github.com/repos/Wikia/mercury/pulls/592/comments","review_comment_url":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/mercury/issues/592/comments","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/9683838ae1f26715087a15f0aa36434da4820068","head":{"label":"Wikia:hapi-auth","ref":"hapi-auth","sha":"9683838ae1f26715087a15f0aa36434da4820068","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-03-12T19:05:42Z","pushed_at":"2015-03-13T00:07:36Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"http://dev.wikia.com","size":16236,"stargazers_count":9,"watchers_count":9,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":9,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"f3e02049e48242b5271b5a0441a724ac80946f26","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":16710430,"name":"mercury","full_name":"Wikia/mercury","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/mercury","description":"Wikia Web application","fork":false,"url":"https://api.github.com/repos/Wikia/mercury","forks_url":"https://api.github.com/repos/Wikia/mercury/forks","keys_url":"https://api.github.com/repos/Wikia/mercury/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/mercury/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/mercury/teams","hooks_url":"https://api.github.com/repos/Wikia/mercury/hooks","issue_events_url":"https://api.github.com/repos/Wikia/mercury/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/mercury/events","assignees_url":"https://api.github.com/repos/Wikia/mercury/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/mercury/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/mercury/tags","blobs_url":"https://api.github.com/repos/Wikia/mercury/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/mercury/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/mercury/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/mercury/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/mercury/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/mercury/languages","stargazers_url":"https://api.github.com/repos/Wikia/mercury/stargazers","contributors_url":"https://api.github.com/repos/Wikia/mercury/contributors","subscribers_url":"https://api.github.com/repos/Wikia/mercury/subscribers","subscription_url":"https://api.github.com/repos/Wikia/mercury/subscription","commits_url":"https://api.github.com/repos/Wikia/mercury/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/mercury/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/mercury/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/mercury/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/mercury/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/mercury/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/mercury/merges","archive_url":"https://api.github.com/repos/Wikia/mercury/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/mercury/downloads","issues_url":"https://api.github.com/repos/Wikia/mercury/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/mercury/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/mercury/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/mercury/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/mercury/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/mercury/releases{/id}","created_at":"2014-02-10T21:44:25Z","updated_at":"2015-03-12T19:05:42Z","pushed_at":"2015-03-13T00:07:36Z","git_url":"git://github.com/Wikia/mercury.git","ssh_url":"git@github.com:Wikia/mercury.git","clone_url":"https://github.com/Wikia/mercury.git","svn_url":"https://github.com/Wikia/mercury","homepage":"http://dev.wikia.com","size":16236,"stargazers_count":9,"watchers_count":9,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":9,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/592"},"html":{"href":"https://github.com/Wikia/mercury/pull/592"},"issue":{"href":"https://api.github.com/repos/Wikia/mercury/issues/592"},"comments":{"href":"https://api.github.com/repos/Wikia/mercury/issues/592/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/592/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/mercury/pulls/592/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/mercury/statuses/9683838ae1f26715087a15f0aa36434da4820068"}}}}